mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-04 22:17:22 +08:00
22 lines
3.6 KiB
Go
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 (_ag "github.com/unidoc/unipdf/v3/internal/bitwise";_de "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_dg "github.com/unidoc/unipdf/v3/internal/jbig2/document";_ac "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_a "image";
|
|
);func (_ca *Decoder )DecodeNextPage ()([]byte ,error ){_ca ._e ++;_fdb :=_ca ._e ;return _ca .decodePage (_fdb );};func (_ge *Decoder )PageNumber ()(int ,error ){const _gf ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";
|
|
if _ge ._f ==nil {return 0,_ac .Error (_gf ,"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 (_ge ._f .NumberOfPages ),nil ;};type Decoder struct{_b _ag .StreamReader ;
|
|
_f *_dg .Document ;_e int ;_g Parameters ;};func (_ff *Decoder )DecodePageImage (pageNumber int )(_a .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";
|
|
_af ,_c :=_ff .decodePageImage (pageNumber );if _c !=nil {return nil ,_ac .Wrap (_c ,_gd ,"");};return _af ,nil ;};func (_aa *Decoder )decodePageImage (_ce int )(_a .Image ,error ){const _ab ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
if _ce < 0{return nil ,_ac .Errorf (_ab ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ce );};if _ce > int (_aa ._f .NumberOfPages ){return nil ,_ac .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",_ce );
|
|
};_cb ,_eb :=_aa ._f .GetPage (_ce );if _eb !=nil {return nil ,_ac .Wrap (_eb ,_ab ,"");};_cbe ,_eb :=_cb .GetBitmap ();if _eb !=nil {return nil ,_ac .Wrap (_eb ,_ab ,"");};_cbe .InverseData ();return _cbe .ToImage (),nil ;};func Decode (input []byte ,parameters Parameters ,globals *_dg .Globals )(*Decoder ,error ){_gfb :=_ag .NewReader (input );
|
|
_ae ,_dee :=_dg .DecodeDocument (_gfb ,globals );if _dee !=nil {return nil ,_dee ;};return &Decoder {_b :_gfb ,_f :_ae ,_g :parameters },nil ;};func (_acf *Decoder )decodePage (_cg int )([]byte ,error ){const _afd ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";
|
|
if _cg < 0{return nil ,_ac .Errorf (_afd ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_cg );};if _cg > int (_acf ._f .NumberOfPages ){return nil ,_ac .Errorf (_afd ,"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",_cg );
|
|
};_gb ,_ec :=_acf ._f .GetPage (_cg );if _ec !=nil {return nil ,_ac .Wrap (_ec ,_afd ,"");};_dd ,_ec :=_gb .GetBitmap ();if _ec !=nil {return nil ,_ac .Wrap (_ec ,_afd ,"");};_dd .InverseData ();if !_acf ._g .UnpaddedData {return _dd .Data ,nil ;};return _dd .GetUnpaddedData ();
|
|
};type Parameters struct{UnpaddedData bool ;Color _de .Color ;};func (_fd *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _fd .decodePage (pageNumber )}; |