2020-10-05 19:28:24 +00:00

12 lines
3.6 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 decoder ;import (_g "github.com/unidoc/unipdf/v3/internal/bitwise";_bb "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_ae "github.com/unidoc/unipdf/v3/internal/jbig2/document";_bf "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_b "image";);type Decoder struct{_ag _g .StreamReader ;_aeg *_ae .Document ;_aa int ;_e Parameters ;};func (_be *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _be .decodePage (pageNumber )};func (_dg *Decoder )decodePageImage (_aacc int )(_b .Image ,error ){const _gf ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _aacc < 0{return nil ,_bf .Errorf (_gf ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_aacc );};if _aacc > int (_dg ._aeg .NumberOfPages ){return nil ,_bf .Errorf (_gf ,"p\u0061\u0067\u0065\u003a\u0020\u0027%\u0064\u0027\u0020\u006e\u006f\u0074 \u0066\u006f\u0075\u006e\u0064\u0020\u0069n\u0020\u0074\u0068\u0065\u0020\u0064\u0065\u0063\u006f\u0064e\u0072",_aacc );};_ba ,_bba :=_dg ._aeg .GetPage (_aacc );if _bba !=nil {return nil ,_bf .Wrap (_bba ,_gf ,"");};_fg ,_bba :=_ba .GetBitmap ();if _bba !=nil {return nil ,_bf .Wrap (_bba ,_gf ,"");};return _fg .ToImage (),nil ;};type Parameters struct{UnpaddedData bool ;Color _bb .Color ;};func (_bfb *Decoder )PageNumber ()(int ,error ){const _dc ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _bfb ._aeg ==nil {return 0,_bf .Error (_dc ,"d\u0065\u0063\u006f\u0064\u0065\u0072 \u006e\u006f\u0074\u0020\u0069\u006e\u0069\u0074\u0069a\u006c\u0069\u007ae\u0064 \u0079\u0065\u0074");};return int (_bfb ._aeg .NumberOfPages ),nil ;};func (_aac *Decoder )DecodePageImage (pageNumber int )(_b .Image ,error ){const _f ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_bea ,_gc :=_aac .decodePageImage (pageNumber );if _gc !=nil {return nil ,_bf .Wrap (_gc ,_f ,"");};return _bea ,nil ;};func Decode (input []byte ,parameters Parameters ,globals *_ae .Globals )(*Decoder ,error ){_bfbb :=_g .NewReader (input );_ef ,_ac :=_ae .DecodeDocument (_bfbb ,globals );if _ac !=nil {return nil ,_ac ;};return &Decoder {_ag :_bfbb ,_aeg :_ef ,_e :parameters },nil ;};func (_d *Decoder )DecodeNextPage ()([]byte ,error ){_d ._aa ++;_c :=_d ._aa ;return _d .decodePage (_c )};func (_aga *Decoder )decodePage (_beb int )([]byte ,error ){const _de ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _beb < 0{return nil ,_bf .Errorf (_de ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_beb );};if _beb > int (_aga ._aeg .NumberOfPages ){return nil ,_bf .Errorf (_de ,"p\u0061\u0067\u0065\u003a\u0020\u0027%\u0064\u0027\u0020\u006e\u006f\u0074 \u0066\u006f\u0075\u006e\u0064\u0020\u0069n\u0020\u0074\u0068\u0065\u0020\u0064\u0065\u0063\u006f\u0064e\u0072",_beb );};_cg ,_fa :=_aga ._aeg .GetPage (_beb );if _fa !=nil {return nil ,_bf .Wrap (_fa ,_de ,"");};_cgd ,_fa :=_cg .GetBitmap ();if _fa !=nil {return nil ,_bf .Wrap (_fa ,_de ,"");};_cgd .InverseData ();if !_aga ._e .UnpaddedData {return _cgd .Data ,nil ;};return _cgd .GetUnpaddedData ();};