mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-27 13:48:51 +08:00
12 lines
1.9 KiB
Go
12 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 (_b "github.com/unidoc/unipdf/v3/internal/bitwise";_g "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_c "github.com/unidoc/unipdf/v3/internal/jbig2/document";_d "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";_gb "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_e "sort";);func DecodeGlobals (encoded []byte )(Globals ,error ){const _db ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_dg :=_b .NewReader (encoded );_af ,_ff :=_c .DecodeDocument (_dg ,nil );if _ff !=nil {return nil ,_gb .Wrap (_ff ,_db ,"");};if _af .GlobalSegments ==nil ||(_af .GlobalSegments .Segments ==nil ){return nil ,_gb .Error (_db ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");};_ad :=Globals {};for _ ,_bf :=range _af .GlobalSegments .Segments {_ad [int (_bf .SegmentNumber )]=_bf ;};return _ad ,nil ;};func DecodeBytes (encoded []byte ,parameters _g .Parameters ,globals ...Globals )([]byte ,error ){var _a Globals ;if len (globals )> 0{_a =globals [0];};_aa ,_fe :=_g .Decode (encoded ,parameters ,_a .ToDocumentGlobals ());if _fe !=nil {return nil ,_fe ;};return _aa .DecodeNextPage ();};func (_gc Globals )ToDocumentGlobals ()*_c .Globals {if _gc ==nil {return nil ;};_de :=[]*_d .Header {};for _ ,_bg :=range _gc {_de =append (_de ,_bg );};_e .Slice (_de ,func (_ag ,_fdf int )bool {return _de [_ag ].SegmentNumber < _de [_fdf ].SegmentNumber });return &_c .Globals {Segments :_de };};type Globals map[int ]*_d .Header ; |