'decompress a doc file using LZS algorithm

https://github.com/sgherro/Exercises-cpp/blob/89bbd78eeac9666ed20f083ebf116e693a8c23ce/Lempel-Ziv-Stac/main.cpp I am using this algorithm to decompress my doc file but it only decompress the partial file data not fully decompress can anyone help me to decompress this file. the data is in hex format. 2812C06040A0000C000400302084005859A242C8300E285401F0804F28008B643379B8E865C185F2A1E4E065399745C78369B040A20200850A00000B4260BFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDD8895659B9843008115EE957D03D22B72A988C0512A85502450FB2C2CA97A00D183D1095826DB5921DAEDF3B90804AA1508150103A84C52995CBDD3CB111B34E0BC1722CD0091F1A0D6526B13CF42C0108D5AD23327964CF749ADF8C05120184282896006296D900C0E368BB7522E8E21011149369059071A23D39078C80E528211275302A124592F82948571FB9C9CC8178C40E3E743D5DCB95A0198260462540E1B06A7C42134580946971A9F55C491E05211613CEA634AA5464E12E2854A40553CD4A515F949C42610885CAB613B91B4851D9A8C0FC30108AA390F341D0DE749A178560813508C71B944A4172F9655EB8591C8A292190E4DA734034CCC994B2C1AE5737338B60910B41329722AC95E942126C3AFF28A39009B01309EA293537DEC7820090821700234E62B61028CC1F4E945F8303781592AC2298D628B6DB60B6B721200A21D18BB1385B089C8200A3E3FDF4045ABC4B2F768124FC6D3E199FCE00FBCC524F66029D082502C4DC852036808501F8BD7E8956B35524875270F0EB011B42CFF43AC4EEAB519498E345800D1EFA7A27D7C4F123AD16E7419A856292801D64F93B33D1CBE9D12FF7F80C013BCF60F24434B7778030213805840160004008BE72329B0E62F1761A9DA7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF92B124C13530C600C203BD06FD41B457A516D30430A3270BCC6D06D861B2070416C924C09CAE03535DFCFD1E361B0022EBA4C24765B49A693681E8E69C231D5C0942EBC034962A83514BD04B59F25E6196DF6BC3C0012A855E29462786B1C1C40C4DB99EC667EB28464914B29068B2C85514CF0D01922F8442619AC009B9454447B3954E0B3488852CF6A18C48B351A78E2556BBDD307E19A8132316AB58D4482D9EC0EAA1E9157C860EAE99C193F4D081FAC52E3316A411EC26F2C8BAC42A3A926B819234D4297A8B0346C180BC4A9C48989580A0D3C178D1751E946BF53B151285160254209448BDF734C0B8122D3F9CE8A730647E3677884B2B42FB84DE1B4E17482F39907EAC16296378B334AE80B32003932000277379C8C82F992E990DE633A9B6DCE8BADC0CCC7C0036E575CEB0C17FFFFFFFFFFFFFFFFA2D128CD2748C408211DE485E10DC83B3884940D05548C4042A4AE0807B818C9B0FA45B0915EBF1C8ED588694A7550AC8F4306387596334F998CAAF1BB7CFA173EA086CAD4923148712108920A5092B558193C8AD3C6F0F124C89025B04762540A44220C6CB92AB43AC2EE81C36896A63481C26590B9A430690821C2AA5531B140E71315806483D94852DD39AD146AE74B0196772F00D9A92321056AEB20BC826CF340AC30D12D985E68B38A0096BC2A9556A251E2A5E4A303A24CE223429428825B238B8D74023098730B16C464267B9DBE86663FD04DD15881B4726684584113E8801EFF2F911D4CB67909CC9B1F8B5988A07886598200C60717300FCF6628BC84C61BB010ABB409A5EC6E700F8C83E24085DACE4E808CCC5C88241200DB4BB38011B08F49BA1DAE1173D096F82AB1210810458C32112058F8571CD9438240CC083D7C9C5E61F910B58EFA18A502403340933625501245023870007793746493479BB07ACB3938C70927BA35B07F203A1605B47140B60F5F974DA4F7C365DA880D1DC8AD91E874F69A4012090424C890682014A55D4546B8F59F3480EC3E302F8C6FE522F8C83309A80885137B652C280BBACA03284081344B308866110CDE2F3B160F80F3AC141D250553895352EDAA1209A05465C0CAD19C4A5F8FDBCFE3A170C4616200D2E7B15040CEA55F020967F1D3FD9EFF7C2E4EEEA1509DEC45080C5D0220413CF61D73AB1A88E51338D2A5090E8DAE1799C1AE9747159426A232ED1CF215AA9B294472A1E8943B0ADEA6A56928FE755A1C88818613DD5C7868394C2C93B39CF859560DCAEF30F0D18C0E7B8AC9C9B75920F8197B144B6BA49A0D9449728E1B6911F8F868D508804786C153B5E608171D556E239BF428773F208FC3B1E2481AE964AA01E5D2B03D266E6A16452D660AA5DAE25380450D87235100623FA482C7A48BBD34266B9D874E8458545A3C401040A612D9D80C387A95DDA0D0F2D9264E5D2CC0CD17AAF5C8BD2F29D6CFF1E2097036598C9D87008BC1DA547D279027C3B23D6AEA010CD045D06168597A71D03709C23C1720DC2872B9089A0A5CAD506E51D2A11E753806114E55D0E1605D2A3097C3F32237883D578597F11556B819BB09A3E57ADD76E034B402ECA55895F4B26A2494CE0781E5803C5A1E40E586C9DC9CEF2D205A4BC7080488307B8314C8F6883060E449348724869A18E4FB7C36CC2BD29A418CEE53ACCA4B52D2FDBABB1EB7A9622DD5C4549B1CBC347F390C6EA0B1D5E45171B3CCE074F1DE2DA158E480A9B82E2ABC15C3607BD55A0A51040BCE05088C02EB0B968E48F9770AD2A83DF66D2F810C2F61B2D4DE987FABC84FA06AFC4CDF5407D36E770B5C56EC1B1D55E621F96832408818526686D5AE15EAA1BE01562D068F70F88820BA0B318C8C80F8D41CED551D8F0703910886DB0E3D000EA7CBF4DEF7763E9DCE17530CDE0F5F9FD74C123A44F26175280DC021BB5C86422D0FC1A3B6E004F03B2D210852671D29C2EBF1E4E9733999E377BA3C466362025B872113753E44481BCEA5C0DA85741124240F0AE199F0C4FE2DB6DCE7912139B25F76AFC64031CA750A271EBAC6E5723B5586831A98DD078348B8369967208889F1D8043E3725A883C886F9A488B91CAB0985E0D6C0331C4EA2F3D3B0B55541722267BB0BE557B93C1C5673265CE0E3A3454A28351E1ECC7074538609CCD0EB44998E8AB4ABFC50BE003516AE315004585B76BC576606B91C2E81699586070581984602263A55EC91E8C0B05B3425130DE7F81DB41D2C25402AE7FA01B660771408E464EB84E2A40323C5E416985474A415A14B0A718A85ACEB049B0247E1E8AC222E16804A23F473C9E0BB61A38E03055AD8DAA814149FCAA56824C6AB1B25860B9573E1EA7966BFD645A39A91F4517A0DD780F250F44ABD2AB843E36359283A464F95064850F13CBED1618ADCAC53F240F43E3908CA0BF2F3C9801D2E3F44AB90D30060206617D687478B3C2CFC2107D180833BBC309628869DCC876B8C34F5481F5F2E4401786C1D13BF48A4877B2CE0F311B7556EDDA8D447A20D22363BF0DE413A8B0A213360B1426B7B82D6EBC6C9D8262C1D279C03A459F4849C73A359C8576BED0A0567BC4C2ED7935918E17CA080E8708B68F66938A6D2A450C94D426E3CA500EAD72278107E7D394E4966C3E982D16832D5CDB3B2D1F2853E3A8747F3FBCDE0F870B7DFECB773B95EEF173610EBB1FB7E4F81711EAE7EB6C72E97192196174283D6A722C385B4765A9E89A04160D1A4E35EB0DD4ED512988C0E03AD46CCE2E16942FE1216864047592D70EC1BB8CE21E69AC1A613389E4B6BF55178CA4867379B8FC301A9AA2A55AC0B4B52B198FE2876AE5D8513995D602B580BD6A28964036730C4163B613CC4CF900BCC68F27992D5CF929A6DF60D5F340F0C62EA01F29F23BD902076CBE4F409048E074EA568442C9B502C902A165AF8FEFB1DAADAAAA560E9B6754A8C8ACD703391DC0200135488D0E241F08B09BDC2C2F77A1554BE0AAA9F4F95DB497A0811BBDBEFFA1484C1017D786316979E6BF36C3CC5EB1D6A941D99C76CC6F05DEF1D00CE821B31894050B4CBC4287194935A38170086E05408067CB95B0DA123192CAC180FDB48A1D205A89740119E0305D0204A3F158F490FF10A99FA863288138B6148D0B02D4387DF0DA7F3A5D43E25BE592D657BE46E81049F8389A1E3687EB885589E1A2D1A2272DA95744E0F951C2992D020206444284266A42104A4B0529417A4E6405962DD3920482E35DC4005B869EC4E59881CA0D25ABD625472105E8AC3AA588E97712C4FE05611CD0EF0339A818792B2184C2A742DCAEF54DA6DB695048B04EE376B95B6163E95DF4240E08576126A3DD1E5C23BF4B2CE163F062F736121A8AB439E0EA1E512F84E127807CCAE4048CC541523A7818C4438B88CAD6810C36CB79031388E51B2D4430271B8082A503BD5E4E6A0BD148F25B95EC31651B19E806CA4D5CEA2EB05703562BC948B1093C50C09283891BC018C7BA1283A053A1D0B84F2E07AA75F1C5703F440DD649D1E83DAA6B3125058BD47941EED81BABD54F549A4DD40B3E34DE0637D32DAC591E3EDF6AF18B9853F701E5C0B2D58A1C02BD0CA1061399F41333564446211940F032D4C06D5834CC8C04D9834A06570005306CE6CF758CC5A9A2118C4041520601ED7513989E225DB254097462A0BE172A1CDC2412D1D128E70489D245D00B61B620633389699178BD32207AA2920E15612670C011C0B43229DEA4D75339DC4B4D9B5C6EB7082CB61109915A640180F4E60B7BA80BCBB18A6CFC5B1D350625A5908CB41F122D11CFE7B01CF6FC7ABB8C2980BB1DFCB83DAF17E793C2E0F2FC3AB50EEB16A9CC664749B7C5831671406AB97D8E41CA327861A67F0B831ECA67630C1A20353C8ECFE62BBC16517C1455A7A289FD325C4F995CC73551316A4A722718AF10AA84BC681491D6A3251AD122B2122814698239E0265F409D4164C05BE0C0761A2BC18F81215D98B235BF956837C34866BC7D359BE22422EDD00630359F85A251D5B21C19A7846B93F3FDEC7F3598C76B30E0B816E523AB47C83052F462E15824890FB7F3B69E218DA2C81C848D03D1A3C434FD66904706F6B05CE42C3604906AC06B9838701D3618C6007B8C0411632751C2770A8984C21B26196C969B85863E6D33426D648BC8C0E568149003C7720DAA6D052F89015281CDA02B93201F6E3753A8D4CC53C3135D60AF5A8D5D46A191D838D4392A8D2BD3F1D0E23B463189E0D773C1C0F064190A86E408B93C502D878C8EC56B490C6F310343497302A892973B2F53099718C916FE1B30866B33E2595F69B03677319381A883D0452E661709D00C41C9DDFC16258B5B84A4F100BE891BB3004940CB19843E5FB341EB33B2F1A03076A106290020E0FE5B1F9B41AE11427D0CD3498C0FEF6092D1042E548391CD0DF80175A898AD978010E654680101A234404034D0098A9A0325691868E228018440C20B04204E1DA401CF77013D950DE0D418509C168887033520C31386C44B13390DCA196A91140C1058C8EC16490CD76F93CB5C44B74352845D8E56CDA1D119A458348295C52122E9103C4D27199BA1624D4CAAD7621339B47AE15087536D978960C8185ABADB455769E8462C47D28C6A82086A309329205D5A2D02058372D198B27D930D61D4608566057AAAD32AC7A0B054DB703D2C2A0BCF00055159A0A73281DAA144A1B5D2E504199A0E5088BE55C168B8BB0F0B0C03849AF56C302B1C1886025184328C3C34124B806188A66C0A8A130602C0C9FA184BAE8104C38A94D2DFF40ED661E8B4A24DAD9981A3E898E05B2B0ACF00F0FBE9781544021FCF6428AC72BD68254C20C319541AE442004B8F060261C434450C904953C2BD463613B0000086B04902302FB98BA2E1E96956AD74B7D121B4F1D0ECD911BF07A6D212B5FF7AC11C175DA8818CA20350AC71620F1D2CB44378508F10331C0892B3B0C8993393D02EA5A9555ECC2E0459416611A856D76117C7C0F71098EEA22C18C369A430C0287E01B816AC5228159C9035AB9B81862105333E516A3A4321C24B5411D478C2210205445ADC8122F88C109453969FA72651CC626848954762C7B2F8FEFB039E4A6DC6C1043AC44AA8546BA2114D1E327408915CB0120509B5E350144D12041C61B2C0BD6A875F58C80399C72530910894666613082530505CA2A34FA00DCFE45BED3AF72C261B4EF501DC4E1C6AAD018A94C8E438DB09102D6627964B927545052821E4C65B28D8AD053234CC895A9ECE6634CAC95E8F7E364AC9E1DA74524141001424B13868208311B796677293B820CF219EC485B079742261762D14E774230466207F180CAD2601884CFC009A4BC83241290855391143E183F0841C91643EDA6FB432FDD085620A444BE1C28826D176AD15E0414069101B12A9112F54C931963E7783D8E846699C1A4961390023A1DB014E244A215BEF12A17DC0D0201D90AE8041D4A81C422085815000305A0A362084C0D590799056083B440B460259D60A6192028694217C3C8A1F380AE1F63B80C48368B553A0412B8D58A10133820500B3605C500D289B88A4C0290C6E2C3C44AC22B204809143A48046D16281583E210F19251259889481001BD326163A04967202281AA1A2B08C0751B16488532EC5ABC6FA81A2C91702984EC1B330E6557C2F11201181F1469E08205E2240D35868BC18A71EA709A58403D95C3C47B2580B1B34526FB530987E062F3DD183C45A911E8271AB4A600590C198F2200D1243C370C9A2B54E0F8AA060D1BC9A681AAF022DD7787452251E924C494119D4D2155B920A869608056E634332AA5A348B4BD6E989900F1311C8C5014B092C006E24D26837EA4D1321E0FAF203318CC2639AA402DB2DC68438229FE46632D4FC66518E956020B881C27E720B4E20901391125A22B9D7EAA8800A9790F186124A108682C24944981B239A0202D081B1F09613BE92A063E1F170BF3394CE6ED400950A11310D9945974AA09C6F5BB453E8173889C2356096D20FF5C119E48E47F90728206CDE5835C68CF65915B06F0828CE4454E9B9A680279447686670DD68FA640D83A3A6F30108A115948CC4175AC9CC6D360D822130A9B8EC1744BD82C286B34C550DB0C63034A75109102054C8D113B0410197DBC5FA8F16971E6C95521590CF5EB20DE14112FC20F9043E0289147A6C82E3693D97EC10B15D709740A1C9ECE093F146C61C81804A11384CB07B450610E8E439D876674F1A0E2DC1492838441FAE1282F721A5DCE55494D90D34BBD92293713E14C8475221D49B6E868947470250306D7A165506276981B845592FCD4E4792D4F2696C2E99AA915B69B021709A49CCB249BD42CD392D42C025B04160F90B2C0DC213002D0A1500A7D54B05D289065E6E000EEFC2EB442A9E6112026DA690792EB664818743E05874F03389A8D3639C3BC3BC92F23B06082840F17C54E240B0416893627DD42D27211629B6F3C4386C28AF4BE6041A9C20C3379A180794901DDE4410984160945C48C5598DA8C17A12C205D0C3E80862293C120542A3C9A06A448A42C5A23244007B90A8D954394AE1B8640043595908BE63A814A426F3343670509855C4B7F0D416F92BB207E043E229F8D30C2BCDA4BB020442525536A231189D0A3790C48EDD02144C42E5D90D824B0F3BD0AB81CB598488760006A3F001611656361559EF2180353C225509DEA6E6FB0030EF5A3A01A541207632C48D41639498B0551A4AC0C27A8CF29C41369EADE32AB53CA314B2056834F14C721B7F09060FA4B21C54A034B1936306A9D86714C03823A470F87B194407D7C8D56E681BBD9360D1D0794EF96EBE5D485229E4E42B5AB691C3E3C82D56ED2201178E5403054A1765AF04A0B6F015301900BC0123D68294CE3331978962E5E090E8EC5ABA8566019108FCD15DAE5336690EC43171744C820B0DC721C799A86E15423EC18C216A20EC054AA35A40A499709ACC640709A3C4EB958ECD17AF86EC8333CC20BE302D862E56A8F4568D4A3E8B02034B64C81F67B38B63677A314F6BE09E525CB2D4D0EF02C3E0B050E23C100A804DD12321C423660E038310E324484B528B04CB942B4290A239A42E638F40ABB04A46AC4060AA6C4B8D158732BA29C6716B23812CC11CA6847994001675B1D9E857124C8E7A630A01E4F5C0B5C07429839001C72108264D1190CCECA550B4BCE1300101E950FB3534FB70819387B253FD7A03010E8BA6F0117548702CC9806B84DAA854C52BC710952A4C24351BE4E6C8ED7C830F1D57E836088CB44458A9870BD6208140DA18A45E0496EB11D40A1C07548640121042551501D433E210E49653C870AA21A145202409859A5D153B9042968AA9F21E3D9EDAED860B6864A0463D8BEE245A3800A559125F61011A199AEC29068B0F557A05F2FA0B04956C0492681A5A7D140FF155072F60A99C2CB48B98ED30A346E504C00552BC1FBBD409826D2FC46A906C060B029B8650B804B42A683A5389C298901819622904A345810894836A22562C47B944C6E112959A2AB6D304FCFD3D1902AB55BAA0CE3B580E4CE890EB51ECB213A14DADB6F3D40CA8329792CD507A941E1D36AC0B439748FA1181C2E2E2AA9B851580109C320EAFF06B45A3D146669870C0857702CD60B5C0F0240C020B1D04E10039C0D1102500D3040A46B759625AE245902153B2566EA5117038ED6FBB97ACE3318CB4BA2ABDD4E096F05020A369BE9149060815588A0BA78D80564A0C60066D8B0E8B4760412CD25811DDA45080F17234659E9A03B2284DF6CD4495086E86C92DBC265C99D58986D89890B32F2B43AE700D2F41DAB05EF86C1B17AF62B8ACE65C1F1AC34FC97C854A5303A48A7912B8322A1F6444F3D5280A76B2C00E53211970F25013C5288149BD165546A19BC964881840AB2D990A26D4F0194E70239D51E7D7FBD9EE84469CCE2EA64BD046516BB2962F52D1F90ADA6716898A21A0F8F8E859874FD9F11E1C259E836911B2685E811894958076B1A150B05F3394C5C4D96CCC701A250F4C23E8C0A4E970195D2C2583C076010C238CEA55FBF9442E5CBCCC8FA8578BD50885343726A9D0A133A98C5C326E3A534CDA6B0F73895472B318B41CC587624D82D53002D6C027C8D512401853E47227C06816C919085B6387CD03F2A230828E5DAC06C304D3CD021A5A975F05E6C951BC7C6C21072B7420F17E9147314D0CE662D9DEFD79A4002BC542B4C6D97A3A58EE710BC04EFB43A1DF6970DA6408CA5303D968C66245E42C103AD0ED551B8C389D4D82184031609C224EA2582245BAE1C41253C0267A54CC1E3423482285B031AE643F198D6BB73A701281200F01882610414E7C513ED78B3A4704D071DD94291B39C70061BAE1B0914C335CE1A58291B49923AC434A9B85816713F9C40679821CCD1600A902B75C9701A8623B65C8166BAEC46902A8297E4B050FD108D721DC5A58149704C85659913AA86E8C92E4919B58286C67A74C28416B54AE673E19CECD50E86464D52191D948C79B64E2C42D9E1B0E6222408EE5682D5E05237B98CC3A5BA31F4C8268DC900C4520D48C604941AA6862BADB01C4E0F476CA5729CC4CF328393A74A3D0160EAB852E01DA9C7099389118464362D572F626BB1146C02AC8521D0F180B4CB73961EE297324572027EA21CC102102530C241AC45037530245E634E96078D215B1020468CD86932BC164E534AF42E946E00C56846B8BDA511314A377F812B44278F043059A09C570D3C9F0D3449F59081419095CAA2091D2A736819CF8CA27231E0906BB3CE2405A91530081F0AC262647018FCE60A2B058061B0C4325B5D1CCA8C61EA293C8014B8591373012E9620E918CD4C8FC92845F9240E355D814E85305A7054DC7286C48750083CF2BC33A4CA34040A0D4539809CD20C249E6CB6F2CD8C781C126F0C15D62340A12D06013B84156E7A52865788355A1042A256A4E3824D46762991C82182F8D5149B7A1C542453431096A20E92C4A605B005F2470438C0259592F8848B5B125CE1007B383C4E49341804601A6C5C9C3B291784933B08143029869849255114727B430215A81333E9C2992198402364EA2C24A13498CDAA4302CDA8CC468A4D418558B950206037014CC31A0DDCA939008F87638071927B86A8AB352C554E64F89E548228CA015C22C322B202ECCA53994824452D9B6781EA39CE926DB0CE2F1441CC58772127044BE640C14492722A892B525149241411BA4DAE628884729F34AA532A03308D36D23A8E0A2D26CA89084B758590AC15E370690FA05C6E003614A048C30B45A3D46C9341BB4A6D57B02CF45F4EB7972464B80C3CD3741CCB0695883170453B1DD402922269A6415C26066EE7D90876B0A9183B1F919583D04B44528C4237098EA3B344C0991A98C54923182158E34492130C527BE170D3303AC2AE003011D30F800A8601299AAA65E0D03D2670AEC611175A4C72F8554426759C93EB7782F95AD6059DC08D05C86CA43D3344E83A36586052D2E9A493521D0C4977112C0E230AB0CA84225A664742C408DC6E8C0EE3E639690CAE48931E8B854854DC927A335EE475DAC856B602824F472312356B4BE09ED46238C8C8A6EB31048B4F3048A236D9BA9A40C91423299A19E257583C30455A241362C01A84E443369C0221868081D2A24B0DA1C40B1D13E90E03323A10B40F483D48E60412F8142A7309D5880B8C05015B0DA4897E9B0DCEA6C3F8E0D808A792ECB7A03872FF4610C047E2D8C8747620078E89543B9D88242726CD8E95D9F050E129AD9CC072CB89B6C520280A46C0638172C036AF4BEAB5423D729A381AC10307C26976F3021705463569490820A638886C120FCD741254F2455D81930997B108DA7F3FB3836F571B8DD26F3C009684F0C221568606BD9EEE63E85140CA4B04A8C6330CA6734BA570B42B950FCD32E1E0DEAA0E19994A04A16480A55B01C0AA9149F9A2784429D8C2D270E96A726C244145A051944C760C34C32F1632A8EA146C01CC24770BA538CE7033170EC44CD384121D34222C3C0E2520F0DDE25D69840008C041B5D241028F0D6B748074846716A457C08430D43C3E27CF204F034C62B3A2458C4F2DB5168E53293962CF3E02C3D27A130C44B328F00D030A982E01C34018E83A2503A23558F802143D1A98C1151351ECFD69109E04D2ABC55A5D0FB54DE07028145A77061BDFCBF006057FBFDD85C2F9BDB638093FC54840F838B6204D8E0DCDA5236496001B9C4DC0D3A34D80F15083D0EC340A58D09B168B5F44865179EE692FBBC36DC5F375D67D46B6CDEB24FB90CC86490B5F24F710D1122D3395540AD12945C8900E3F9CC3761A85189530BACA4743CAB1B859529687ABC1E2B8BA5D2B361F0D46024D36CC56BCC7E8F27A1C6E067FBEC38C0798469802551C767EB2802DE19BFA8CA34922B378261B640652CC94DD242B9B0351B9191EB16B1F87AB279ADDD27D7D8D55AB33B2525C030114327B839246607299249822341AC8D4C84CEA93792309EDD7C9957A5D338DD5A8F76B188ABB7CBC4349F1C97D84CB25B0D2E4A5D8E1A43B1D81DD6F4168DC72BB6F38404290EBECF2A0273B52007712B064349EC03309255E66BD98D27AAB5C6511428C3CE368B11EAF123800A4710CA25203966C4546803586CD4232410AE52995EA9E0898840225BB1C94053F27004BF5FAA8BA5417AC83A96288200A947430856C75A8A8EA84238F530193F935E4962D468C56BF0AA4E0C82C481A77941321505BC50C1BBF98653E9848867610E05C2E2E1E9021E0635508E111194F8382A0C9C01D12B604A774E37430ED22381488E90483E43259F6120F0350AE9350CD8045463ACECBA263DDB27B6804A5F2011D6B915B3400CA3821C0A27663D97252163491C5910AF9F0C64AA080CD877AFDF8DB050633011D0485683D31AB2970C55316166CD0A0D81CB06801018E1561ADE800388113E5A0E87430D1428F88A811C00042A44D8C1C2823E9590EA661260480174184600E218345A7452248E873370590E46759B986E0322E9935D715C677C381AC412F8496A2F46009A44C0CB45C6265A0C10CEB7A28C228502BAD8A720E997C03E858AF04AA51C8050BC1F4D308978B2517B96844103921134882D0DD4299273D51A5D2506C506D3393CCEFA039D5E885651A00AA81ABA068B3276505FB1CC01801985D25D560CD4C5F3CB05EC1F3625094E658944CA7A31348A0DA6809D06B027384DAE83CB6D265278ACC06A359200667D58134784042100560660004E8D5441FD8CD23C0F936C003AEC420B02889223946A8C20EC6C8F16E9D579EC205B3BAE90CEE5F2B97C6E5E4B802D9C98A5F411087E13713B9F8322F98000761425054244AA45EE910B8497A7876394786F7DA2D105F1D008A4BF0E21900CD3B810A0A1B8483620201005B2D99CC4CF7A1D4EFD70C241550C5E2D50996118042B23C7C3B31278EE0B4C210FCEA4724AB60355B2A5543DC06D65C025FC540D3B54E5B562C9B05A5F848880A75B2492F05E1A472DC03A0C76E561884AD579148E80F118288C0F5420270C04E823F09006684A38188F43C09358121816401C0361B3A1585B1B28CA4185455CC12251D04955BA01A8C031A086C0211B016C30A2109879543CD428210240428C1937008A60B11C78763E9C1E769B1FAA14C389BC5E5B071009F6E90CA2C6301FDE07F2FA44E4C2283CCA81848854F6825082080091895CEEC642810905D480B57E98253E0B60E3F8ED689845A391E2B2BBB04E0C04B398EC3532C8F6E7709357A761E2BD10FE3318500677311DBA330696E7221896093469242E6852AC4EC12733A9540A3FA7824E745AA9D8CB62814401900AE8466227B9A210161206B5800DD4B77FB38DA34F681532051FC4E5E96852FA4DA8DB4BB71C31C6A878620531825E84022320B87C9F703A0601402517082978256D23CA136F084481888D8EBF0458280A065AEC91D0C548304922110E5200553CD3502F9F4887C0A8FAF57A08D4A1C69AED32006A249AE3167234240C318CDA8162B01162935643305F5F7450189B4AF02819CC0C479B0AE1846231F60A148B89EAE500D08074490343EA501A38C27A50199028E1199DE0E65C0BDE20526985EE64520E1E0C2080A03C92210948C428898094492C78505FAD406223194D5EE606BACDC1372170CE90751412E7265BD40B4C40784543ABDD4D563344C2AE61AEDDEE83797882155BAB84A301E08D841B6F04DDE8D7017DD0AD62B40B8DE4E370625D2D960CEE751A5598BB40349CC820A89582281A60C504BF477804DC1A00B0D104242B98EA4208850C00324B8004CD1EB0042CC32860E6453218DB84F7739D9281088295A32231B930930180448666028C90180FB598256012B50E18031256D6861A4412C96D04811C81C04916F0D1484104BAC4CEA480218C4204B3C38544F990E6647210DB2EC5E180FA3E092B046801E89598887B365A4764029478581DA2DD6BF7D261F62E009C03C7F25939E6340E8B86E2F1B300208A0EA6CD66628A5478CC0EB09729220051282D30309153CA080C7139740F3751164E3D3A9D4532502D0A3258200300C91806035275804C28A94CC050BB0CD371F02C230BB818A277CA6892C070B180E1C5306D84996A34464F02B2A9EA83531003423230696F45D118072F8887A56113B04AB95F251B66C53804721F523ECB31A6136C6641F9FEE52BB40FE3C4A3009AE87196638E050AA40488C198F3610D4204A3D0C08842459ED081472388162C0A85998342D019D6252E829680E6B38090F95C319968E3C25138696CAA1D94CB0CE50760B19C15292F4FEF77B391BA9B94580557B2CBC5F6097D2E3E4C0214A7C0AB65A2BC2D0692CCF6C32048B90E80DEA49620FC9245540B076AB28B05188A0434016F30B9985214001E41C60683B9A299450F61A4208366E21991242B7B3C0F041761FCF64406BD2800055863B74E70508C130E020A1C80705D907F40C1B2F3438F8202030AB1E028032F0F8903B0B220227DC60C03379087E2996102D03C1E9B4635D05562477881900545339080BA22348CC842499C7C2752234122630040F6137B17496705627DF40C641BCA098108C83A191215904B6241093E730125D66E47F371BC0318A84B21B5796056561C1F16AEA70885F68E221F08AEF57841481E1C0B0B8AD21385ECEC652FC06750DA85888861BB1243550A0C5CA1402C5067152BC094325B8D178F31F330BADB1032DC2354F8CCF8773D3C0DCBB6DAEDB4B70A2D06C8C72BE4C8CC061A1BC674AADC42EC252ECA64030A9C12B956B198AC76B094D6356D234D63C49B341C587EABD2ECDBF310D41E2997F195C8AC26388FE3E9FD03E55951A8247F0747AC81DB74E0B159BF024A03007090520C87458C31423C2E174C8A50C079410EE229216A4761389226C1D0B05C790A091367F3BB34B2ED792E0A2AF0BD38479979A46E269294078360A5503A4BAAC0A33129502E5D44844F04BF80931AB05263E333980E450D2743E721E301DAA1720B878D7461A4C4E02B065765F5111D121E478592EA256BA2AA81C844175801186123D3B06602641C19AE96F104920B1998D1AA3488D0AE945C8FE71611DD2534D8F86A640E909D24C7FBF04C4123AC11C3648B00F8924A1998A915118DBCF04D0BDD2C32D9741882228E9F47E33049EE3034395E65D14A61C63F351912ED44693CBC206B05826907B164264F5D3786E7B7491C8AF243BCE7701317A3C55AE096DF77944D48F129D8A28F18965BCA2533C45E624E8F9DACE1C94000BD2006C98F361AA1F4F44009D3A74501CC00B362D35C46B59FE4D76AC0E2482B1EE84C17D767A3E9D5C4753D85D446044AE1F20E5F8FF1E1C8F0B55630DF2E2158E878BC3A84DE0040950C838B0C843511A1188442A2608ADA3D0E0AAE00C28170345C1E102FB0F19C2A1E1DBB516664CB4DE6F0122E03AD87237954B12AA7148A53D889F4FE17BBD2E0D77B08B449231C5B6F26EB24A20C37065F4AD54BB1AE14491758279300BC8057671BDDCE6029143EF47205026911A8F15834082984ED042BD8780E67BA94E9B4BA61E85460064B0F1708FD463F71BA5F0DD4F274B81E0D145D02C2896C3ABA3C3289AFF3A9E8EEC7373FC46D0103257403558E4845B750FD82820493528AD420043AA17020532A46D3255A955EA20044420309F8D704909E0C974839F8C5118FDC0AE400B4FC1C47B6922811EA7C76F40430DE818572D5A6EA622993FB51C80D26333242C40C094DB8C480F5287D76C75B95826CC4EBA9E0820309DFADA5A0F1505F769F1F83A06A3800C071ADCB0444418428C013940B0870BA51A08904931FC641883D80A7042CC1C7B96F833268DDEC6929208BAE86C0E1F46C762D430B325A85F49238A28927A398B9D0132B2045EB54403DD873362901A2536858787C348F112FA761F884E7070018CBD35B95F0B02D2BD7BC316AD25C94D04954837578664FA69DAEB633B5DA5369B39EAA41D3FDE86351B55F0783A8DD927A2313172DF542443A4B1F9C51A6702A45FE242F97890725FB4DD8C914BD048DC1F311484365020A85015BAC946348BF48EB8783844B0B711C8C3C11D1ED60494C588540A8D16EA08BC10A5D2D01436EB6E0CC865536AB44A9E7A185A6F2500C9BA7A1E91406E45FAC9307E4E144EF2541022D48340EEE52BA5CA42D489A84A6E12ACC7E376883CE8C25B2A17ACB6A1D93ACE563C958B66C2546ABE5CBF038F84BB97BA2BDCE480F374F0125E3BCB8D8213094A5F0EB7C441D27058A0A27B21DBEFE62A69AE97668E9F6D07E2A5B26E2E1B818350F894F61E56878408E70359AAAD7219D2A5B1CAE263615444B242BC1847D79099E2842C80CBEFB6F97CB8CF47BE47EEE7EACD3A855A3342B2E31D0E4598B94A6F02201767557A00246F4429128D23691E960001721D220719650478BCC0144615952D804A75C0E173B61741623259371F61640F4FB5C5C2E40A559A354534DE0B7358F8207F4F81D148D653C19AC67FAA5367E5F114A8CA7991D2067519345E5B5C895312980982F0291AFBE0ED4AC42A1A95CC44604986BE32B0528504B20D64A5619C5E4FA36BD5D4DD59279CE9F4A0F4FE39C1849259801AFB5EAD13E9B4D82808A427B49C2B1A4D0B796002F753B128EA5CB05FA9A561083CEE7FBBC7E5B45BD0DA9F6C252D960BC82717B139660A2E26DA6D6511B114663297164C67F18102CB36B093EF47FAB9C6415628C961B68BE1EA657B5F9C36078EAC4368AD24EF58C888023EC261F061FCC03C0603420A342DB487B395B810053BD6C3C72BA852DE75164D454072BDBC5E5E6201FA484EBE30845709B348BC664F78984BEF0ACE0967402846282D8F032A26835CAA61731510D39C1A60C6FBE9B4BA2D2ECCA2F702DDAE3352A3DDE2E5ED4D8449FCC2D85DB14E21A4F9541C6B64AC5943E7E1F8E6724A0615E617789C9C3354A1CE0FF6405D4253401C0F25252B2D1C762703CCC8F3EB68A0FA6A1DCF29A153B88A9C2F3D8C4474B924E6812B0E1EB3D80B492269F9200E153F5D8E8381087ED24990DCEFF0380000FF7F80C00502580C096A500C000463C00084000F4A85C4CE800E2C70E440004B0E000EE6F391905E66379BCE86EC186598C078369B15894669B9C6200831DDE2B7AD6A877024ECDA2A2A42AA743919527A2D9B4EE1F4018838A30D018028E49ADCBE8C5FB494C8A4E2982E6C43265BEFC309812C8F3D944083B530340E99501A034A24012414294BB6C08FD7DAED322C281805891148A480B202075304147AAD365F658A99C0056011964CA5C0D2622554409652B4AA3163219CC4C080CC2A9C350C120D9148150221658E0CAB801275C4590C215FC4F34A8198184BBC112C80E8C550C568BF4705A55125CA8235B803AA61CB452CED03918E831322383EF0710CC909C370342893370C4062D441D4A6BD62A09D0F729134385708B2DBE7860BB5822161BEC1C03048A96A8C2DB114934610EC446A51ECD322BA062794DA406AD0290C0D27D232B0B2E11A20068392BBF5328A77B49B8626F104ECE71B2C426457395D52E8772E816B1372A8640063B20DE4B14A288CF93C988288E541211AE811B1890F84C2CCA6220425C86E2378759AD170919E6CB002CC26C05E9852E21730B4049B418613C4652AD9AE557C96486A9030697E8E7B089BE7B2B375602E302D56F45E00C9B75B1178E6222E54E2C343F1649550324B6E10A2E5B407571F102AF201417E125A0E8D4A720855B683391F90C29512240A8D4E226EE026888DE28AE552EB6BBA53E0442B84D83D6D8B1CCB5438DD5A5923329849E573F1ECA666BB4CCD13234DEAD033B0156257B0D86E2A1F9D8D4BE2A118825A175A282F9787EAB9608587225D92CE048F934986A9FE3ECC863E9C409318C92C02CD8E904E100860C90C79194E43217485972259926E6D8C0208677815F40E013BC12251A938262139381B4554812CC2347700DA0145A881C40249259D83E3EA1DACE25C1A406392313D7A68108E5BEFC618651C743BAFDCA952B8CCDA4A14C4EC2E3E990634132968143CA30FCAC4922C36E40C92C884A150A4B08C3B33140FB74B1C1E7726A50B2ED40AD46051519A1180A3595508B150815C6C42E3C9246A34990CC2F54B90B0662C924326E52138E2E803BF9FC49349253231701A89C4426831D4703A0ED1C963534900B101978C25A081B5B2F6600209C86263C05ABE7C875885F438982A131826492CD44A14AE9D31939E8F323174012190B6AE65AA9683B203E9AE3D23318D0A322B50422E030A59C2435294E8B76F1091EF16DA6858246E9C04CEC6F08DACAC01034A49851151869E793DDA460593A042F52D905A8BC7535C6A2A5C0E95E200B1B4AC0E600C5E4BB2A3C954557F0D862F02399188210322C6212471F5EC4A1C0A58AC178AED6CE662B980C9369801C22B602D4C2A7108983A024D8747E1C46919CAE732BE482CB468E9A0CA799A11EE23C98172563A80956AB4B25C2A6C6704DE654080148E9969BA062172924CEA0545081EE1E5233DB71DA0E6A7021354291152BD12A000A9DBE63723ECC2F83CA5998511FAD0C0196C951ACCD122DCFCF232B78B42C7ABF9EC643B85500A24D150624A522D0982376198644D1C16CD498350D102C3219814E45752A1EA4C681088543603C676E902C901001ECB2EA746CD13B1592A393E03850740088184C8072F81A2D2CADD5CF548BAC4AC96CADC1A5F5BBB8E2B70503C84DB659E0960850129CED0442F5C2695A94D608335B98487615B7C8E2E42AC4F40560C40C239182355B14A9930AE8CC685D2707A7C7A8F2122160F08E5BAFD88614C08934583B05194CB19260FABE250F90AFB3223DE0D7221085CB54A365226F1DA7570B73FA853E4118835A45D4F13D50E3380444C37499C4EADC548C104A84A9F1A0656D0BDE4DB3CBCD661F042B9FE543D3FD46B43181CF18606CFD02CA8C9627D0E048FB691C6588A829D6CB13DC632C4968969627A994432C4D3ACB138692C45042116B64DEDF50AD47069681016CD14585924F3668FD38E12403D1E3B2C8192A002D9A12A90689D4900250AE1BC141512D90EF6AB89D48E02358631D914A5611084F66164B8DC8EB4BA1C744E0E810D0AD36170369E483707213299A8F22E122CDAEB2702815A4E6E8D5AE92750D05AB8502D50C0D46B08A2783C0C940B958058BACD4C2A9302516A39DE86688D9811A61ECC00DB28E606273B11C8C68B2520315EA9CEE7F41B918ED05A45701394C1A928D2085461280CAF2D9CD0A5C61971622E9FE8ED08865BC760C275202D542E08A5C7A94978496E120D26F4E814192C2130CC1AB7C94A16E304460528A880D08F0BC983F13DCAB91A271983B243D4B2104A8B176755A865BA5C2B041E6261591DC0107C9B454656C8A1FE9C1C0280E646208CF48B10849BCFB7625090565428DC6B39610CD732398CA700A881E802D8AC9C434616C08B53D9E4781A5AB245CCB7904DD0AD1CB4914CB3433DD4B533BE65852B52CB70A9B05E1379A48668323965E4F81C94C34D85D1108A987D801A6170E0C820F8299084CD824134A0C76C2006F4E70248628BD0DABA4C244DC68171496C2D4EA7CB2DC43A2DDEB36318812876DA2DB6970422856561319231404C80A84F92502495881138AA40B85C2615C34CD4E354B54A8F12E18CE6C10F39DF8406F034C12C20F89D6B3C4DC5A0B064FC0E1C1D80224713203CBF06834321A6BBC19CF549195C4E72B2B836F75A1748A7B50B36CAA0940C5037199B08841BFA5840DD712C21C2255B0AD9E230BB28745830BC07CD5588D518236BA016002151044CCB74B4D1E20783ADF6854B9E1F6470E158300666224E6425498D4A97501D5F4CE48A6C88FE769FD10152C0E57A4E4FB50268A1B2688E8B5DBC520A276AA94A719A80FF0BA4C7E00C0929FFA32B58AC77738073436C0D840238300177BC329B8C977AF56D8C018C77780DEC0E433B912EC560A464232703C16327A0D958DB01AA1641C05AD488414949907691CFEB72684470CD172C88A911FBF84A4A2E0FC3855088710875091D084A23CCA751CA90A4EF09D2B8679B96C2240BCC98A7560005A123952481E1B17C7E2C95D62D0548185E5C40021DAE2653C108E46F26D3052639CD42984D8AD922D1C321F89C41A8920654902CB48126BA4448C613999E587030872CC7BA0DD20339A9186F1718D0B46A2CA15823578239E49C2C8BD1C2311AE834B25237DD2EA1E9213A6F06A31A0B84C204AACC71B51DCA9313D94A3419B9034E672ACC58A41F88464BC778C52090693A97043660185333A1B84A74D8884227524B706B64042F4AB417CC9242B45050019A12E4B19A7152FA160342EF30F1C970B444A0C547A5FB2888775B975106D2DA561D2114FC572515568CA92B0A3381088A6A6204062456136D38BD09315481E099FDD4682F074DCB45E039603801B7076710E989B221540ED52F134950CC7FDD07F2D0A19A4849ADDA21E7AB2D80AA7DB542AAC772D978BE60BBAB4E13C72337C2502A8F0FBDC342C3D8B8A0116B0F980F2029340A827D25520CD6C137FA3D84E833713830664C81C96D01234D08CC513199EE00A4CBC7D0EC4327D1B02E3B2ACCAED68A622B418CCAE16795CFC35533756EDD55134CCEB30B20803735B69B0701A70844BE4901703BB54A2E4DB99E4F42F18DF09F129F930EC41371E2DF36BFA3F8C85BE9CC911B3E41F4B54BC0790994B5F134194C264329C8622EBBCABC4A96CDE9B1805100DF13BB47E205F89C0CD2220512A546D1416CBE2292DAE7763A61C0152F99036487B3ACCEEE748C8AAA448BD904F15C9F1CEF80E17C3C1E478B0EE4A510D02A3C01379B80507384B0244A07C44F0799E4660B4028C1B7ED1940513C564088343CD74F8FC7A5430A585

enter image description here The image I upload is screen shot of a bkf file for a single image file. I know sharing screenshot does not good but can you help by seeing this data from which section I have to start CROP so the file image data is not corrupt format. Because according to me compressed data is start from after 18 byte of FH. because when some file data is not compressed then starting of data is from FH block. http://laytongraphics.com/mtf/MTF_100a.PDF in this link page no-70-71 explain format of compressed data, after that page no- 109-110 is explain algo but I cannot find it any link for that. If you understand my query please help me.



Solution 1:[1]

The compressed data is in the Lempel-Ziv-Stac format, documented in many places, including RFC 1967. It is a very simple compressed data format. Here is code that can decompress that format:

/*
  unlzs version 1.0, 16 May 2022

  Copyright (C) 2022 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.

  Mark Adler
  [email protected]
 */

// Decompress LZS (Lempel-Ziv-Stac) compressed data. See RFC 1967 for the
// compressed data format description, or ANSI X3.241-1994 for the official
// standard.

#include <stdio.h>
#include <setjmp.h>

// Bitstream for pulling sequences of bits from the input.
typedef struct {
    int bits;           // number of bits in the buffer
    long buf;           // bit buffer, with least significant being newest
    FILE *in;           // input file
    jmp_buf bad;        // longjmp state for use if end of input reached
} bitstream_t;

// Return bits bits from the stream bs. Long jump if EOF reached before bits
// bits can be pulled. This can support up to 25 bits requested, for a 32-bit
// long. (The most requested here is 11.)
static inline long get(bitstream_t *bs, int bits) {
    while (bs->bits < bits) {
        int ch = getc(bs->in);
        if (ch == EOF)
            longjmp(bs->bad, 1);
        bs->buf = (bs->buf << 8) + ch;
        bs->bits += 8;
    }
    bs->bits -= bits;
    return (bs->buf >> bs->bits) & ((1L << bits) - 1);
}

// Sliding window for matching byte patterns to copy. This is a circular buffer
// of the last 2K bytes of uncompressed data.
#define WSIZE 2048                  // LZS window size
typedef struct {
    unsigned next;                  // index of next location in window[]
    int full;                       // true if the window is full
    FILE *out;                      // file to write output to
    unsigned char window[WSIZE];    // sliding window
} window_t;

// Write one byte to the output, updating the sliding window.
static inline void put(window_t *win, unsigned octet) {
    win->window[win->next++] = octet;
    if (win->next == sizeof(win->window)) {
        win->next = 0;
        win->full = 1;
    }
    putc(octet, win->out);
}

// Decompress LZS from in to out. Return 0 on success, 1 if the input ends
// prematurely, 2 if a distance extends past the start of the input (like
// trying to look back in time before the Big Bang), 3 for an invalid distance
// code (using 11 bits for a distance when 7 bits would suffice -- this is a
// constraint from a shall statement in the ANSI standard), or 4 if the final
// padding bits are not zero (also a shall statement). A distance past the
// start of input error is the most common error encountered on random input,
// by far. That error likely indicates that the input is not LZS-compressed
// data in the first place.
static int unlzs(FILE *in, FILE *out) {
    bitstream_t bs = {0, 0, in, {0}};
    if (setjmp(bs.bad))
        return 1;                   // premature end of input
    window_t win = {0, 0, out, {0}};
    for (;;) {
        if (get(&bs, 1)) {
            // Get distance, length pair.
            unsigned num = get(&bs, 1) ? 7 : 11;
            unsigned dist = get(&bs, num);
            if (num == 11 && dist < 128)
                return 3;           // invalid distance code
            if (dist == 0) {
                // End marker.
                if (get(&bs, bs.bits) != 0)
                    return 4;       // padding bits not zero
                return 0;           // clean end of input
            }
            unsigned base = 2;
            unsigned len = get(&bs, 2);
            if (len == 3) {
                base += len;
                len = get(&bs, 2);
                if (len == 3) {
                    base += len;
                    while ((len = get(&bs, 4)) == 15)
                        base += len;
                }
            }
            len += base;

            // Copy len bytes from dist back in the window.
            if (!win.full && dist > win.next)
                return 2;           // distance too far
            do {
                put(&win, win.window[(win.next - dist) & (WSIZE - 1)]);
            } while (--len);
        }
        else
            // Get and write a literal.
            put(&win, get(&bs, 8));
    }
}

// Return the number of bytes left to be read from in.
static unsigned long left(FILE *in) {
    unsigned long n = 0;
    while (getc(in) != EOF)
        n++;
    return n;
}

// Decompress LZS from stdin to stdout.
int main(void) {
    int ret = unlzs(stdin, stdout);
    unsigned long n = left(stdin);
    if (ret == 1)
        fputs("premature end of input\n", stderr);
    else if (ret == 2)
        fprintf(stderr, "distance too far (%lu left)\n", n);
    else if (ret == 3)
        fprintf(stderr, "invalid distance code (%lu left)\n", n);
    else if (ret == 4)
        fprintf(stderr, "padding bits at end not zero (%lu left)\n", n);
    else if (n)
        fprintf(stderr, "%lu bytes of junk after compressed data\n", n);
    return ret;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1