mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-26 13:48:55 +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 (_g "github.com/unidoc/unipdf/v3/internal/bitwise";_b "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_cf "github.com/unidoc/unipdf/v3/internal/jbig2/document";_c "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";_d "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_gf "sort";);func DecodeGlobals (encoded []byte )(Globals ,error ){const _gc ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_cd :=_g .NewReader (encoded );_ea ,_f :=_cf .DecodeDocument (_cd ,nil );if _f !=nil {return nil ,_d .Wrap (_f ,_gc ,"");};if _ea .GlobalSegments ==nil ||(_ea .GlobalSegments .Segments ==nil ){return nil ,_d .Error (_gc ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");};_gfg :=Globals {};for _ ,_gd :=range _ea .GlobalSegments .Segments {_gfg [int (_gd .SegmentNumber )]=_gd ;};return _gfg ,nil ;};func DecodeBytes (encoded []byte ,parameters _b .Parameters ,globals ...Globals )([]byte ,error ){var _ef Globals ;if len (globals )> 0{_ef =globals [0];};_gfe ,_dc :=_b .Decode (encoded ,parameters ,_ef .ToDocumentGlobals ());if _dc !=nil {return nil ,_dc ;};return _gfe .DecodeNextPage ();};type Globals map[int ]*_c .Header ;func (_eb Globals )ToDocumentGlobals ()*_cf .Globals {if _eb ==nil {return nil ;};_gg :=[]*_c .Header {};for _ ,_a :=range _eb {_gg =append (_gg ,_a );};_gf .Slice (_gg ,func (_efc ,_fd int )bool {return _gg [_efc ].SegmentNumber < _gg [_fd ].SegmentNumber });return &_cf .Globals {Segments :_gg };}; |