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 (_e "github.com/unidoc/unipdf/v3/internal/bitwise";_g "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_gf "github.com/unidoc/unipdf/v3/internal/jbig2/document";_a "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";
|
|
_ga "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_eg "sort";);func DecodeBytes (encoded []byte ,parameters _g .Parameters ,globals ...Globals )([]byte ,error ){var _d Globals ;if len (globals )> 0{_d =globals [0];};_ee ,_gfb :=_g .Decode (encoded ,parameters ,_d .ToDocumentGlobals ());
|
|
if _gfb !=nil {return nil ,_gfb ;};return _ee .DecodeNextPage ();};type Globals map[int ]*_a .Header ;func DecodeGlobals (encoded []byte )(Globals ,error ){const _ge ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_ff :=_e .NewReader (encoded );
|
|
_ad ,_gb :=_gf .DecodeDocument (_ff ,nil );if _gb !=nil {return nil ,_ga .Wrap (_gb ,_ge ,"");};if _ad .GlobalSegments ==nil ||(_ad .GlobalSegments .Segments ==nil ){return nil ,_ga .Error (_ge ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");
|
|
};_ed :=Globals {};for _ ,_ab :=range _ad .GlobalSegments .Segments {_ed [int (_ab .SegmentNumber )]=_ab ;};return _ed ,nil ;};func (_b Globals )ToDocumentGlobals ()*_gf .Globals {if _b ==nil {return nil ;};_c :=[]*_a .Header {};for _ ,_bf :=range _b {_c =append (_c ,_bf );
|
|
};_eg .Slice (_c ,func (_ffd ,_eb int )bool {return _c [_ffd ].SegmentNumber < _c [_eb ].SegmentNumber });return &_gf .Globals {Segments :_c };}; |