mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +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 (_g "github.com/unidoc/unipdf/v3/internal/bitwise";_c "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_a "github.com/unidoc/unipdf/v3/internal/jbig2/document";_d "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";
|
|
_de "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_b "sort";);func DecodeGlobals (encoded []byte )(Globals ,error ){const _gb ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_ge :=_g .NewReader (encoded );_bg ,_bc :=_a .DecodeDocument (_ge ,nil );
|
|
if _bc !=nil {return nil ,_de .Wrap (_bc ,_gb ,"");};if _bg .GlobalSegments ==nil ||(_bg .GlobalSegments .Segments ==nil ){return nil ,_de .Error (_gb ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");
|
|
};_e :=Globals {};for _ ,_ccc :=range _bg .GlobalSegments .Segments {_e [int (_ccc .SegmentNumber )]=_ccc ;};return _e ,nil ;};func DecodeBytes (encoded []byte ,parameters _c .Parameters ,globals ...Globals )([]byte ,error ){var _cc Globals ;if len (globals )> 0{_cc =globals [0];
|
|
};_fd ,_da :=_c .Decode (encoded ,parameters ,_cc .ToDocumentGlobals ());if _da !=nil {return nil ,_da ;};return _fd .DecodeNextPage ();};type Globals map[int ]*_d .Header ;func (_eb Globals )ToDocumentGlobals ()*_a .Globals {if _eb ==nil {return nil ;
|
|
};_ec :=[]*_d .Header {};for _ ,_ebb :=range _eb {_ec =append (_ec ,_ebb );};_b .Slice (_ec ,func (_ca ,_cb int )bool {return _ec [_ca ].SegmentNumber < _ec [_cb ].SegmentNumber });return &_a .Globals {Segments :_ec };}; |