mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-02 22:17:06 +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 (_dd "github.com/unidoc/unipdf/v3/internal/bitwise";_f "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_c "github.com/unidoc/unipdf/v3/internal/jbig2/document";_gc "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";_dg "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_g "sort";);type Globals map[int ]*_gc .Header ;func (_ac Globals )ToDocumentGlobals ()*_c .Globals {if _ac ==nil {return nil ;};_ca :=[]*_gc .Header {};for _ ,_gg :=range _ac {_ca =append (_ca ,_gg );};_g .Slice (_ca ,func (_e ,_fc int )bool {return _ca [_e ].SegmentNumber < _ca [_fc ].SegmentNumber });return &_c .Globals {Segments :_ca };};func DecodeGlobals (encoded []byte )(Globals ,error ){const _fd ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_a :=_dd .NewReader (encoded );_ad ,_df :=_c .DecodeDocument (_a ,nil );if _df !=nil {return nil ,_dg .Wrap (_df ,_fd ,"");};if _ad .GlobalSegments ==nil ||(_ad .GlobalSegments .Segments ==nil ){return nil ,_dg .Error (_fd ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");};_ga :=Globals {};for _ ,_da :=range _ad .GlobalSegments .Segments {_ga [int (_da .SegmentNumber )]=_da ;};return _ga ,nil ;};func DecodeBytes (encoded []byte ,parameters _f .Parameters ,globals ...Globals )([]byte ,error ){var _fa Globals ;if len (globals )> 0{_fa =globals [0];};_b ,_cg :=_f .Decode (encoded ,parameters ,_fa .ToDocumentGlobals ());if _cg !=nil {return nil ,_cg ;};return _b .DecodeNextPage ();}; |