unipdf/internal/jbig2/jbig2.go

17 lines
1.9 KiB
Go
Raw Normal View History

2020-08-27 21:45:09 +00:00
//
// 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/
2024-06-27 16:15:49 +00:00
package jbig2 ;import (_a "github.com/unidoc/unipdf/v3/internal/bitwise";_ac "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_e "github.com/unidoc/unipdf/v3/internal/jbig2/document";_d "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";
_f "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_gd "sort";);func (_dc Globals )ToDocumentGlobals ()*_e .Globals {if _dc ==nil {return nil ;};_ec :=[]*_d .Header {};for _ ,_gaa :=range _dc {_ec =append (_ec ,_gaa );};_gd .Slice (_ec ,func (_bf ,_fg int )bool {return _ec [_bf ].SegmentNumber < _ec [_fg ].SegmentNumber });
return &_e .Globals {Segments :_ec };};type Globals map[int ]*_d .Header ;func DecodeBytes (encoded []byte ,parameters _ac .Parameters ,globals ...Globals )([]byte ,error ){var _gb Globals ;if len (globals )> 0{_gb =globals [0];};_b ,_fb :=_ac .Decode (encoded ,parameters ,_gb .ToDocumentGlobals ());
if _fb !=nil {return nil ,_fb ;};return _b .DecodeNextPage ();};func DecodeGlobals (encoded []byte )(Globals ,error ){const _bc ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_ga :=_a .NewReader (encoded );_c ,_bb :=_e .DecodeDocument (_ga ,nil );
if _bb !=nil {return nil ,_f .Wrap (_bb ,_bc ,"");};if _c .GlobalSegments ==nil ||(_c .GlobalSegments .Segments ==nil ){return nil ,_f .Error (_bc ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");
};_ff :=Globals {};for _ ,_gg :=range _c .GlobalSegments .Segments {_ff [int (_gg .SegmentNumber )]=_gg ;};return _ff ,nil ;};