mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-07 19:29:16 +08:00
17 lines
1.9 KiB
Go
17 lines
1.9 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
package jbig2 ;import (_a "github.com/unidoc/unipdf/v3/internal/bitwise";_b "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_f "github.com/unidoc/unipdf/v3/internal/jbig2/document";_d "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";
|
|
_df "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_c "sort";);func DecodeGlobals (encoded []byte )(Globals ,error ){const _ff ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_gb :=_a .NewReader (encoded );_dd ,_ca :=_f .DecodeDocument (_gb ,nil );
|
|
if _ca !=nil {return nil ,_df .Wrap (_ca ,_ff ,"");};if _dd .GlobalSegments ==nil ||(_dd .GlobalSegments .Segments ==nil ){return nil ,_df .Error (_ff ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");
|
|
};_fe :=Globals {};for _ ,_ac :=range _dd .GlobalSegments .Segments {_fe [int (_ac .SegmentNumber )]=_ac ;};return _fe ,nil ;};func (_bd Globals )ToDocumentGlobals ()*_f .Globals {if _bd ==nil {return nil ;};_aa :=[]*_d .Header {};for _ ,_cb :=range _bd {_aa =append (_aa ,_cb );
|
|
};_c .Slice (_aa ,func (_aeb ,_fg int )bool {return _aa [_aeb ].SegmentNumber < _aa [_fg ].SegmentNumber });return &_f .Globals {Segments :_aa };};func DecodeBytes (encoded []byte ,parameters _b .Parameters ,globals ...Globals )([]byte ,error ){var _cg Globals ;
|
|
if len (globals )> 0{_cg =globals [0];};_fa ,_ad :=_b .Decode (encoded ,parameters ,_cg .ToDocumentGlobals ());if _ad !=nil {return nil ,_ad ;};return _fa .DecodeNextPage ();};type Globals map[int ]*_d .Header ; |