mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-07 19:29:16 +08:00
17 lines
1.9 KiB
Go
17 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 (_da "github.com/unidoc/unipdf/v3/internal/bitwise";_a "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_f "github.com/unidoc/unipdf/v3/internal/jbig2/document";_g "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";
|
|
_c "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_dc "sort";);func (_gb Globals )ToDocumentGlobals ()*_f .Globals {if _gb ==nil {return nil ;};_fc :=[]*_g .Header {};for _ ,_gba :=range _gb {_fc =append (_fc ,_gba );};_dc .Slice (_fc ,func (_cg ,_dg int )bool {return _fc [_cg ].SegmentNumber < _fc [_dg ].SegmentNumber });
|
|
return &_f .Globals {Segments :_fc };};func DecodeGlobals (encoded []byte )(Globals ,error ){const _df ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_ae :=_da .NewReader (encoded );_e ,_aea :=_f .DecodeDocument (_ae ,nil );
|
|
if _aea !=nil {return nil ,_c .Wrap (_aea ,_df ,"");};if _e .GlobalSegments ==nil ||(_e .GlobalSegments .Segments ==nil ){return nil ,_c .Error (_df ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");
|
|
};_db :=Globals {};for _ ,_ed :=range _e .GlobalSegments .Segments {_db [int (_ed .SegmentNumber )]=_ed ;};return _db ,nil ;};type Globals map[int ]*_g .Header ;func DecodeBytes (encoded []byte ,parameters _a .Parameters ,globals ...Globals )([]byte ,error ){var _cf Globals ;
|
|
if len (globals )> 0{_cf =globals [0];};_de ,_ce :=_a .Decode (encoded ,parameters ,_cf .ToDocumentGlobals ());if _ce !=nil {return nil ,_ce ;};return _de .DecodeNextPage ();}; |