2020-09-28 23:18:17 +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 (_a "github.com/unidoc/unipdf/v3/internal/bitwise";_ac "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_f "github.com/unidoc/unipdf/v3/internal/jbig2/document";_c "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_g "image";);func (_bd *Decoder )DecodePageImage (pageNumber int )(_g .Image ,error ){const _de ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_bf ,_fg :=_bd .decodePageImage (pageNumber );if _fg !=nil {return nil ,_c .Wrap (_fg ,_de ,"");};return _bf ,nil ;};type Decoder struct{_b _a .StreamReader ;_gb *_f .Document ;_e int ;_ag Parameters ;};func (_aa *Decoder )DecodeNextPage ()([]byte ,error ){_aa ._e ++;_fb :=_aa ._e ;return _aa .decodePage (_fb );};type Parameters struct{UnpaddedData bool ;Color _ac .Color ;};func (_eg *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _eg .decodePage (pageNumber )};func (_af *Decoder )decodePageImage (_abf int )(_g .Image ,error ){const _egb ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _abf < 0{return nil ,_c .Errorf (_egb ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_abf );};if _abf > int (_af ._gb .NumberOfPages ){return nil ,_c .Errorf (_egb ,"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",_abf );};_ce ,_dg :=_af ._gb .GetPage (_abf );if _dg !=nil {return nil ,_c .Wrap (_dg ,_egb ,"");};_gbe ,_dg :=_ce .GetBitmap ();if _dg !=nil {return nil ,_c .Wrap (_dg ,_egb ,"");};return _gbe .ToImage (),nil ;};func (_bb *Decoder )decodePage (_bc int )([]byte ,error ){const _ec ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _bc < 0{return nil ,_c .Errorf (_ec ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_bc );};if _bc > int (_bb ._gb .NumberOfPages ){return nil ,_c .Errorf (_ec ,"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",_bc );};_bbg ,_fgc :=_bb ._gb .GetPage (_bc );if _fgc !=nil {return nil ,_c .Wrap (_fgc ,_ec ,"");};_abc ,_fgc :=_bbg .GetBitmap ();if _fgc !=nil {return nil ,_c .Wrap (_fgc ,_ec ,"");};_abc .InverseData ();if !_bb ._ag .UnpaddedData {return _abc .Data ,nil ;};return _abc .GetUnpaddedData ();};func Decode (input []byte ,parameters Parameters ,globals *_f .Globals )(*Decoder ,error ){_gd :=_a .NewReader (input );_ge ,_fe :=_f .DecodeDocument (_gd ,globals );if _fe !=nil {return nil ,_fe ;};return &Decoder {_b :_gd ,_gb :_ge ,_ag :parameters },nil ;};func (_ab *Decoder )PageNumber ()(int ,error ){const _fd ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _ab ._gb ==nil {return 0,_c .Error (_fd ,"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 (_ab ._gb .NumberOfPages ),nil ;};