mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-02 22:17:06 +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 (_d "github.com/unidoc/unipdf/v3/internal/bitwise";_ad "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_gb "github.com/unidoc/unipdf/v3/internal/jbig2/document";_g "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_c "image";);func (_b *Decoder )DecodeNextPage ()([]byte ,error ){_b ._gf ++;_df :=_b ._gf ;return _b .decodePage (_df );};func (_ac *Decoder )decodePageImage (_fea int )(_c .Image ,error ){const _de ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _fea < 0{return nil ,_g .Errorf (_de ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_fea );};if _fea > int (_ac ._adc .NumberOfPages ){return nil ,_g .Errorf (_de ,"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",_fea );};_ce ,_bcd :=_ac ._adc .GetPage (_fea );if _bcd !=nil {return nil ,_g .Wrap (_bcd ,_de ,"");};_ba ,_bcd :=_ce .GetBitmap ();if _bcd !=nil {return nil ,_g .Wrap (_bcd ,_de ,"");};return _ba .ToImage (),nil ;};func (_bc *Decoder )decodePage (_dd int )([]byte ,error ){const _bf ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _dd < 0{return nil ,_g .Errorf (_bf ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_dd );};if _dd > int (_bc ._adc .NumberOfPages ){return nil ,_g .Errorf (_bf ,"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",_dd );};_gcf ,_fe :=_bc ._adc .GetPage (_dd );if _fe !=nil {return nil ,_g .Wrap (_fe ,_bf ,"");};_bff ,_fe :=_gcf .GetBitmap ();if _fe !=nil {return nil ,_g .Wrap (_fe ,_bf ,"");};_bff .InverseData ();if !_bc ._ga .UnpaddedData {return _bff .Data ,nil ;};return _bff .GetUnpaddedData ();};func (_cd *Decoder )DecodePageImage (pageNumber int )(_c .Image ,error ){const _gab ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_aeg ,_ge :=_cd .decodePageImage (pageNumber );if _ge !=nil {return nil ,_g .Wrap (_ge ,_gab ,"");};return _aeg ,nil ;};type Decoder struct{_ae _d .StreamReader ;_adc *_gb .Document ;_gf int ;_ga Parameters ;};type Parameters struct{UnpaddedData bool ;Color _ad .Color ;};func (_aa *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _aa .decodePage (pageNumber )};func Decode (input []byte ,parameters Parameters ,globals *_gb .Globals )(*Decoder ,error ){_bg :=_d .NewReader (input );_e ,_ade :=_gb .DecodeDocument (_bg ,globals );if _ade !=nil {return nil ,_ade ;};return &Decoder {_ae :_bg ,_adc :_e ,_ga :parameters },nil ;};func (_gc *Decoder )PageNumber ()(int ,error ){const _f ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _gc ._adc ==nil {return 0,_g .Error (_f ,"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 (_gc ._adc .NumberOfPages ),nil ;}; |