mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +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 (_g "github.com/unidoc/unipdf/v3/internal/bitwise";_ge "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_fe "github.com/unidoc/unipdf/v3/internal/jbig2/document";_fb "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_e "image";
|
|
);func (_gd *Decoder )DecodeNextPage ()([]byte ,error ){_gd ._d ++;_egf :=_gd ._d ;return _gd .decodePage (_egf );};type Decoder struct{_c _g .StreamReader ;_ec *_fe .Document ;_d int ;_gf Parameters ;};func (_a *Decoder )decodePage (_ff int )([]byte ,error ){const _bg ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";
|
|
if _ff < 0{return nil ,_fb .Errorf (_bg ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ff );};if _ff > int (_a ._ec .NumberOfPages ){return nil ,_fb .Errorf (_bg ,"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",_ff );
|
|
};_fec ,_af :=_a ._ec .GetPage (_ff );if _af !=nil {return nil ,_fb .Wrap (_af ,_bg ,"");};_cae ,_af :=_fec .GetBitmap ();if _af !=nil {return nil ,_fb .Wrap (_af ,_bg ,"");};_cae .InverseData ();if !_a ._gf .UnpaddedData {return _cae .Data ,nil ;};return _cae .GetUnpaddedData ();
|
|
};func (_ba *Decoder )decodePageImage (_baf int )(_e .Image ,error ){const _fa ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _baf < 0{return nil ,_fb .Errorf (_fa ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_baf );
|
|
};if _baf > int (_ba ._ec .NumberOfPages ){return nil ,_fb .Errorf (_fa ,"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",_baf );
|
|
};_db ,_dg :=_ba ._ec .GetPage (_baf );if _dg !=nil {return nil ,_fb .Wrap (_dg ,_fa ,"");};_eb ,_dg :=_db .GetBitmap ();if _dg !=nil {return nil ,_fb .Wrap (_dg ,_fa ,"");};_eb .InverseData ();return _eb .ToImage (),nil ;};func (_be *Decoder )DecodePageImage (pageNumber int )(_e .Image ,error ){const _fg ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
_gg ,_eg :=_be .decodePageImage (pageNumber );if _eg !=nil {return nil ,_fb .Wrap (_eg ,_fg ,"");};return _gg ,nil ;};func Decode (input []byte ,parameters Parameters ,globals *_fe .Globals )(*Decoder ,error ){_bf :=_g .NewReader (input );_ea ,_gb :=_fe .DecodeDocument (_bf ,globals );
|
|
if _gb !=nil {return nil ,_gb ;};return &Decoder {_c :_bf ,_ec :_ea ,_gf :parameters },nil ;};func (_b *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _b .decodePage (pageNumber )};type Parameters struct{UnpaddedData bool ;Color _ge .Color ;
|
|
};func (_bc *Decoder )PageNumber ()(int ,error ){const _ca ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _bc ._ec ==nil {return 0,_fb .Error (_ca ,"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 (_bc ._ec .NumberOfPages ),nil ;}; |