2023-12-17 13:54:01 +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 (_c "github.com/unidoc/unipdf/v3/internal/bitwise";_d "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_cc "github.com/unidoc/unipdf/v3/internal/jbig2/document";_aa "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_g "image";
);type Decoder struct{_aac *_c .Reader ;_f *_cc .Document ;_fd int ;_ce Parameters ;};func (_gb *Decoder )DecodePageImage (pageNumber int )(_g .Image ,error ){const _gf ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
_af ,_ac :=_gb .decodePageImage (pageNumber );if _ac !=nil {return nil ,_aa .Wrap (_ac ,_gf ,"");};return _af ,nil ;};func (_fc *Decoder )DecodeNextPage ()([]byte ,error ){_fc ._fd ++;_df :=_fc ._fd ;return _fc .decodePage (_df );};type Parameters struct{UnpaddedData bool ;
Color _d .Color ;};func (_bgf *Decoder )decodePageImage (_e int )(_g .Image ,error ){const _ag ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _e < 0{return nil ,_aa .Errorf (_ag ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_e );
};if _e > int (_bgf ._f .NumberOfPages ){return nil ,_aa .Errorf (_ag ,"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",_e );
};_de ,_gc :=_bgf ._f .GetPage (_e );if _gc !=nil {return nil ,_aa .Wrap (_gc ,_ag ,"");};_fdc ,_gc :=_de .GetBitmap ();if _gc !=nil {return nil ,_aa .Wrap (_gc ,_ag ,"");};_fdc .InverseData ();return _fdc .ToImage (),nil ;};func Decode (input []byte ,parameters Parameters ,globals *_cc .Globals )(*Decoder ,error ){_dec :=_c .NewReader (input );
_bf ,_acc :=_cc .DecodeDocument (_dec ,globals );if _acc !=nil {return nil ,_acc ;};return &Decoder {_aac :_dec ,_f :_bf ,_ce :parameters },nil ;};func (_da *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _da .decodePage (pageNumber )};func (_gfa *Decoder )decodePage (_ad int )([]byte ,error ){const _dc ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";
if _ad < 0{return nil ,_aa .Errorf (_dc ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ad );};if _ad > int (_gfa ._f .NumberOfPages ){return nil ,_aa .Errorf (_dc ,"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",_ad );
};_cf ,_bg :=_gfa ._f .GetPage (_ad );if _bg !=nil {return nil ,_aa .Wrap (_bg ,_dc ,"");};_fcg ,_bg :=_cf .GetBitmap ();if _bg !=nil {return nil ,_aa .Wrap (_bg ,_dc ,"");};_fcg .InverseData ();if !_gfa ._ce .UnpaddedData {return _fcg .Data ,nil ;};return _fcg .GetUnpaddedData ();
};func (_b *Decoder )PageNumber ()(int ,error ){const _gg ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _b ._f ==nil {return 0,_aa .Error (_gg ,"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 (_b ._f .NumberOfPages ),nil ;};