2020-09-21 01:20:10 +00:00

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 (_b "github.com/unidoc/unipdf/v3/internal/bitwise";_f "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_e "github.com/unidoc/unipdf/v3/internal/jbig2/document";_af "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_a "image";);func (_d *Decoder )DecodePageImage (pageNumber int )(_a .Image ,error ){const _cb ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";_eg ,_fd :=_d .decodePageImage (pageNumber );if _fd !=nil {return nil ,_af .Wrap (_fd ,_cb ,"");};return _eg ,nil ;};func (_bc *Decoder )decodePageImage (_cdb int )(_a .Image ,error ){const _ec ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _cdb < 0{return nil ,_af .Errorf (_ec ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_cdb );};if _cdb > int (_bc ._bg .NumberOfPages ){return nil ,_af .Errorf (_ec ,"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",_cdb );};_agd ,_be :=_bc ._bg .GetPage (_cdb );if _be !=nil {return nil ,_af .Wrap (_be ,_ec ,"");};_fab ,_be :=_agd .GetBitmap ();if _be !=nil {return nil ,_af .Wrap (_be ,_ec ,"");};return _fab .ToImage (),nil ;};type Decoder struct{_c _b .StreamReader ;_bg *_e .Document ;_ag int ;_fe Parameters ;};type Parameters struct{UnpaddedData bool ;Color _f .Color ;};func (_cd *Decoder )PageNumber ()(int ,error ){const _ba ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _cd ._bg ==nil {return 0,_af .Error (_ba ,"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 (_cd ._bg .NumberOfPages ),nil ;};func (_ce *Decoder )decodePage (_fa int )([]byte ,error ){const _cc ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _fa < 0{return nil ,_af .Errorf (_cc ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_fa );};if _fa > int (_ce ._bg .NumberOfPages ){return nil ,_af .Errorf (_cc ,"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",_fa );};_gb ,_cbe :=_ce ._bg .GetPage (_fa );if _cbe !=nil {return nil ,_af .Wrap (_cbe ,_cc ,"");};_ff ,_cbe :=_gb .GetBitmap ();if _cbe !=nil {return nil ,_af .Wrap (_cbe ,_cc ,"");};_ff .InverseData ();if !_ce ._fe .UnpaddedData {return _ff .Data ,nil ;};return _ff .GetUnpaddedData ();};func (_egf *Decoder )DecodeNextPage ()([]byte ,error ){_egf ._ag ++;_fb :=_egf ._ag ;return _egf .decodePage (_fb );};func Decode (input []byte ,parameters Parameters ,globals *_e .Globals )(*Decoder ,error ){_afg :=_b .NewReader (input );_bf ,_feb :=_e .DecodeDocument (_afg ,globals );if _feb !=nil {return nil ,_feb ;};return &Decoder {_c :_afg ,_bg :_bf ,_fe :parameters },nil ;};func (_eb *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _eb .decodePage (pageNumber )};