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-05-29 17:04:37 +00:00
package jbig2 ;import (_db "github.com/unidoc/unipdf/v3/internal/bitwise";_df "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_fb "github.com/unidoc/unipdf/v3/internal/jbig2/document";_dg "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";
_b "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_f "sort";);func (_ee Globals )ToDocumentGlobals ()*_fb .Globals {if _ee ==nil {return nil ;};_c :=[]*_dg .Header {};for _ ,_bc :=range _ee {_c =append (_c ,_bc );};_f .Slice (_c ,func (_eea ,_ab int )bool {return _c [_eea ].SegmentNumber < _c [_ab ].SegmentNumber });
return &_fb .Globals {Segments :_c };};type Globals map[int ]*_dg .Header ;func DecodeBytes (encoded []byte ,parameters _df .Parameters ,globals ...Globals )([]byte ,error ){var _be Globals ;if len (globals )> 0{_be =globals [0];};_e ,_a :=_df .Decode (encoded ,parameters ,_be .ToDocumentGlobals ());
if _a !=nil {return nil ,_a ;};return _e .DecodeNextPage ();};func DecodeGlobals (encoded []byte )(Globals ,error ){const _eb ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_fc :=_db .NewReader (encoded );_bf ,_g :=_fb .DecodeDocument (_fc ,nil );
if _g !=nil {return nil ,_b .Wrap (_g ,_eb ,"");};if _bf .GlobalSegments ==nil ||(_bf .GlobalSegments .Segments ==nil ){return nil ,_b .Error (_eb ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");
};_af :=Globals {};for _ ,_eg :=range _bf .GlobalSegments .Segments {_af [int (_eg .SegmentNumber )]=_eg ;};return _af ,nil ;};