unipdf/internal/jbig2/jbig2.go
2020-09-28 23:18:17 +00:00

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 (_c "github.com/unidoc/unipdf/v3/internal/bitwise";_g "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";_ca "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_ac "sort";);func DecodeBytes (encoded []byte ,parameters _g .Parameters ,globals ...Globals )([]byte ,error ){var _b Globals ;if len (globals )> 0{_b =globals [0];};_cad ,_bb :=_g .Decode (encoded ,parameters ,_b .ToDocumentGlobals ());if _bb !=nil {return nil ,_bb ;};return _cad .DecodeNextPage ();};type Globals map[int ]*_d .Header ;func (_gdc Globals )ToDocumentGlobals ()*_f .Globals {if _gdc ==nil {return nil ;};_cf :=[]*_d .Header {};for _ ,_gb :=range _gdc {_cf =append (_cf ,_gb );};_ac .Slice (_cf ,func (_cg ,_bbb int )bool {return _cf [_cg ].SegmentNumber < _cf [_bbb ].SegmentNumber });return &_f .Globals {Segments :_cf };};func DecodeGlobals (encoded []byte )(Globals ,error ){const _fa ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_af :=_c .NewReader (encoded );_gg ,_gd :=_f .DecodeDocument (_af ,nil );if _gd !=nil {return nil ,_ca .Wrap (_gd ,_fa ,"");};if _gg .GlobalSegments ==nil ||(_gg .GlobalSegments .Segments ==nil ){return nil ,_ca .Error (_fa ,"\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 _ ,_bc :=range _gg .GlobalSegments .Segments {_ad [int (_bc .SegmentNumber )]=_bc ;};return _ad ,nil ;};