mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-27 13:48:51 +08:00
12 lines
3.6 KiB
Go
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 (_c "github.com/unidoc/unipdf/v3/internal/bitwise";_e "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_b "github.com/unidoc/unipdf/v3/internal/jbig2/document";_f "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_a "image";);func (_bf *Decoder )DecodePageImage (pageNumber int )(_a .Image ,error ){const _fa ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_bg ,_gb :=_bf .decodePageImage (pageNumber );if _gb !=nil {return nil ,_f .Wrap (_gb ,_fa ,"");};return _bg ,nil ;};func (_ga *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _ga .decodePage (pageNumber )};type Parameters struct{UnpaddedData bool ;Color _e .Color ;};type Decoder struct{_d _c .StreamReader ;_fg *_b .Document ;_ae int ;_eb Parameters ;};func (_ac *Decoder )PageNumber ()(int ,error ){const _af ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _ac ._fg ==nil {return 0,_f .Error (_af ,"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 (_ac ._fg .NumberOfPages ),nil ;};func (_aff *Decoder )decodePage (_ad int )([]byte ,error ){const _be ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _ad < 0{return nil ,_f .Errorf (_be ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ad );};if _ad > int (_aff ._fg .NumberOfPages ){return nil ,_f .Errorf (_be ,"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 );};_fd ,_adb :=_aff ._fg .GetPage (_ad );if _adb !=nil {return nil ,_f .Wrap (_adb ,_be ,"");};_gd ,_adb :=_fd .GetBitmap ();if _adb !=nil {return nil ,_f .Wrap (_adb ,_be ,"");};_gd .InverseData ();if !_aff ._eb .UnpaddedData {return _gd .Data ,nil ;};return _gd .GetUnpaddedData ();};func (_fb *Decoder )DecodeNextPage ()([]byte ,error ){_fb ._ae ++;_gg :=_fb ._ae ;return _fb .decodePage (_gg );};func (_ca *Decoder )decodePageImage (_bc int )(_a .Image ,error ){const _da ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _bc < 0{return nil ,_f .Errorf (_da ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_bc );};if _bc > int (_ca ._fg .NumberOfPages ){return nil ,_f .Errorf (_da ,"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 );};_fe ,_dg :=_ca ._fg .GetPage (_bc );if _dg !=nil {return nil ,_f .Wrap (_dg ,_da ,"");};_fgf ,_dg :=_fe .GetBitmap ();if _dg !=nil {return nil ,_f .Wrap (_dg ,_da ,"");};return _fgf .ToImage (),nil ;};func Decode (input []byte ,parameters Parameters ,globals *_b .Globals )(*Decoder ,error ){_ada :=_c .NewReader (input );_fad ,_gc :=_b .DecodeDocument (_ada ,globals );if _gc !=nil {return nil ,_gc ;};return &Decoder {_d :_ada ,_fg :_fad ,_eb :parameters },nil ;}; |