unipdf/internal/jbig2/jbig2.go
2020-11-11 18:48:37 +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 (_b "github.com/unidoc/unipdf/v3/internal/bitwise";_d "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_dc "github.com/unidoc/unipdf/v3/internal/jbig2/document";_c "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";_ag "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_a "sort";);func DecodeGlobals (encoded []byte )(Globals ,error ){const _ac ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_ed :=_b .NewReader (encoded );_de ,_f :=_dc .DecodeDocument (_ed ,nil );if _f !=nil {return nil ,_ag .Wrap (_f ,_ac ,"");};if _de .GlobalSegments ==nil ||(_de .GlobalSegments .Segments ==nil ){return nil ,_ag .Error (_ac ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");};_fd :=Globals {};for _ ,_dg :=range _de .GlobalSegments .Segments {_fd [int (_dg .SegmentNumber )]=_dg ;};return _fd ,nil ;};func DecodeBytes (encoded []byte ,parameters _d .Parameters ,globals ...Globals )([]byte ,error ){var _e Globals ;if len (globals )> 0{_e =globals [0];};_ee ,_ad :=_d .Decode (encoded ,parameters ,_e .ToDocumentGlobals ());if _ad !=nil {return nil ,_ad ;};return _ee .DecodeNextPage ();};type Globals map[int ]*_c .Header ;func (_bd Globals )ToDocumentGlobals ()*_dc .Globals {if _bd ==nil {return nil ;};_ca :=[]*_c .Header {};for _ ,_def :=range _bd {_ca =append (_ca ,_def );};_a .Slice (_ca ,func (_bc ,_ga int )bool {return _ca [_bc ].SegmentNumber < _ca [_ga ].SegmentNumber });return &_dc .Globals {Segments :_ca };};