2021-03-23 23:12:52 +00:00

22 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 (_a "github.com/unidoc/unipdf/v3/internal/bitwise";_fb "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_fd "github.com/unidoc/unipdf/v3/internal/jbig2/document";_d "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_e "image";
);func Decode (input []byte ,parameters Parameters ,globals *_fd .Globals )(*Decoder ,error ){_de :=_a .NewReader (input );_bb ,_ee :=_fd .DecodeDocument (_de ,globals );if _ee !=nil {return nil ,_ee ;};return &Decoder {_df :_de ,_g :_bb ,_b :parameters },nil ;
};func (_dc *Decoder )DecodePageImage (pageNumber int )(_e .Image ,error ){const _fe ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_db ,_eb :=_dc .decodePageImage (pageNumber );
if _eb !=nil {return nil ,_d .Wrap (_eb ,_fe ,"");};return _db ,nil ;};func (_da *Decoder )PageNumber ()(int ,error ){const _gd ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _da ._g ==nil {return 0,_d .Error (_gd ,"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 (_da ._g .NumberOfPages ),nil ;};func (_bc *Decoder )decodePageImage (_dd int )(_e .Image ,error ){const _ab ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _dd < 0{return nil ,_d .Errorf (_ab ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_dd );
};if _dd > int (_bc ._g .NumberOfPages ){return nil ,_d .Errorf (_ab ,"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",_dd );
};_abd ,_gb :=_bc ._g .GetPage (_dd );if _gb !=nil {return nil ,_d .Wrap (_gb ,_ab ,"");};_gg ,_gb :=_abd .GetBitmap ();if _gb !=nil {return nil ,_d .Wrap (_gb ,_ab ,"");};_gg .InverseData ();return _gg .ToImage (),nil ;};func (_ea *Decoder )DecodeNextPage ()([]byte ,error ){_ea ._eg ++;
_egb :=_ea ._eg ;return _ea .decodePage (_egb );};type Decoder struct{_df _a .StreamReader ;_g *_fd .Document ;_eg int ;_b Parameters ;};func (_c *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _c .decodePage (pageNumber )};func (_dg *Decoder )decodePage (_gf int )([]byte ,error ){const _fg ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";
if _gf < 0{return nil ,_d .Errorf (_fg ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_gf );};if _gf > int (_dg ._g .NumberOfPages ){return nil ,_d .Errorf (_fg ,"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",_gf );
};_ef ,_fba :=_dg ._g .GetPage (_gf );if _fba !=nil {return nil ,_d .Wrap (_fba ,_fg ,"");};_gc ,_fba :=_ef .GetBitmap ();if _fba !=nil {return nil ,_d .Wrap (_fba ,_fg ,"");};_gc .InverseData ();if !_dg ._b .UnpaddedData {return _gc .Data ,nil ;};return _gc .GetUnpaddedData ();
};type Parameters struct{UnpaddedData bool ;Color _fb .Color ;};