2021-06-21 14:01:56 +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 (_b "github.com/unidoc/unipdf/v3/internal/bitwise";_ba "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_d "github.com/unidoc/unipdf/v3/internal/jbig2/document";_e "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_fc "image";
);type Decoder struct{_ed _b .StreamReader ;_a *_d .Document ;_edb int ;_c Parameters ;};func Decode (input []byte ,parameters Parameters ,globals *_d .Globals )(*Decoder ,error ){_bd :=_b .NewReader (input );_ega ,_cdd :=_d .DecodeDocument (_bd ,globals );
if _cdd !=nil {return nil ,_cdd ;};return &Decoder {_ed :_bd ,_a :_ega ,_c :parameters },nil ;};func (_dd *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _dd .decodePage (pageNumber )};func (_gf *Decoder )DecodeNextPage ()([]byte ,error ){_gf ._edb ++;
_ca :=_gf ._edb ;return _gf .decodePage (_ca );};func (_ab *Decoder )decodePage (_ce int )([]byte ,error ){const _abb ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _ce < 0{return nil ,_e .Errorf (_abb ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ce );
};if _ce > int (_ab ._a .NumberOfPages ){return nil ,_e .Errorf (_abb ,"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",_ce );
};_ef ,_dc :=_ab ._a .GetPage (_ce );if _dc !=nil {return nil ,_e .Wrap (_dc ,_abb ,"");};_fa ,_dc :=_ef .GetBitmap ();if _dc !=nil {return nil ,_e .Wrap (_dc ,_abb ,"");};_fa .InverseData ();if !_ab ._c .UnpaddedData {return _fa .Data ,nil ;};return _fa .GetUnpaddedData ();
};type Parameters struct{UnpaddedData bool ;Color _ba .Color ;};func (_cd *Decoder )decodePageImage (_eg int )(_fc .Image ,error ){const _gdc ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _eg < 0{return nil ,_e .Errorf (_gdc ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_eg );
};if _eg > int (_cd ._a .NumberOfPages ){return nil ,_e .Errorf (_gdc ,"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",_eg );
};_dg ,_gc :=_cd ._a .GetPage (_eg );if _gc !=nil {return nil ,_e .Wrap (_gc ,_gdc ,"");};_ff ,_gc :=_dg .GetBitmap ();if _gc !=nil {return nil ,_e .Wrap (_gc ,_gdc ,"");};_ff .InverseData ();return _ff .ToImage (),nil ;};func (_gd *Decoder )PageNumber ()(int ,error ){const _cg ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";
if _gd ._a ==nil {return 0,_e .Error (_cg ,"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 (_gd ._a .NumberOfPages ),nil ;};func (_fb *Decoder )DecodePageImage (pageNumber int )(_fc .Image ,error ){const _db ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
_g ,_aa :=_fb .decodePageImage (pageNumber );if _aa !=nil {return nil ,_e .Wrap (_aa ,_db ,"");};return _g ,nil ;};