22 lines
3.6 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/
2023-09-07 17:40:17 +00:00
package decoder ;import (_g "github.com/unidoc/unipdf/v3/internal/bitwise";_f "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_af "github.com/unidoc/unipdf/v3/internal/jbig2/document";_a "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_ba "image";
);type Decoder struct{_e *_g .Reader ;_bg *_af .Document ;_gg int ;_fg Parameters ;};func (_fc *Decoder )DecodeNextPage ()([]byte ,error ){_fc ._gg ++;_ee :=_fc ._gg ;return _fc .decodePage (_ee );};func Decode (input []byte ,parameters Parameters ,globals *_af .Globals )(*Decoder ,error ){_df :=_g .NewReader (input );
_bd ,_agf :=_af .DecodeDocument (_df ,globals );if _agf !=nil {return nil ,_agf ;};return &Decoder {_e :_df ,_bg :_bd ,_fg :parameters },nil ;};type Parameters struct{UnpaddedData bool ;Color _f .Color ;};func (_ggc *Decoder )decodePageImage (_ae int )(_ba .Image ,error ){const _gb ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
if _ae < 0{return nil ,_a .Errorf (_gb ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ae );};if _ae > int (_ggc ._bg .NumberOfPages ){return nil ,_a .Errorf (_gb ,"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",_ae );
};_ed ,_bae :=_ggc ._bg .GetPage (_ae );if _bae !=nil {return nil ,_a .Wrap (_bae ,_gb ,"");};_ag ,_bae :=_ed .GetBitmap ();if _bae !=nil {return nil ,_a .Wrap (_bae ,_gb ,"");};_ag .InverseData ();return _ag .ToImage (),nil ;};func (_fd *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _fd .decodePage (pageNumber )};
func (_ga *Decoder )decodePage (_de int )([]byte ,error ){const _eg ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _de < 0{return nil ,_a .Errorf (_eg ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_de );
};if _de > int (_ga ._bg .NumberOfPages ){return nil ,_a .Errorf (_eg ,"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",_de );
};_fdb ,_c :=_ga ._bg .GetPage (_de );if _c !=nil {return nil ,_a .Wrap (_c ,_eg ,"");};_ded ,_c :=_fdb .GetBitmap ();if _c !=nil {return nil ,_a .Wrap (_c ,_eg ,"");};_ded .InverseData ();if !_ga ._fg .UnpaddedData {return _ded .Data ,nil ;};return _ded .GetUnpaddedData ();
};func (_d *Decoder )DecodePageImage (pageNumber int )(_ba .Image ,error ){const _gd ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_db ,_ef :=_d .decodePageImage (pageNumber );
if _ef !=nil {return nil ,_a .Wrap (_ef ,_gd ,"");};return _db ,nil ;};func (_afd *Decoder )PageNumber ()(int ,error ){const _fb ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _afd ._bg ==nil {return 0,_a .Error (_fb ,"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 (_afd ._bg .NumberOfPages ),nil ;};