2024-04-16 11:40:43 +00:00

23 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 (_ga "github.com/unidoc/unipdf/v3/internal/bitwise";_gb "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_bc "github.com/unidoc/unipdf/v3/internal/jbig2/document";_b "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_e "image";
);func (_aa *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _aa .decodePage (pageNumber )};func (_c *Decoder )decodePageImage (_cf int )(_e .Image ,error ){const _af ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
if _cf < 0{return nil ,_b .Errorf (_af ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_cf );};if _cf > int (_c ._a .NumberOfPages ){return nil ,_b .Errorf (_af ,"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",_cf );
};_afg ,_fa :=_c ._a .GetPage (_cf );if _fa !=nil {return nil ,_b .Wrap (_fa ,_af ,"");};_afc ,_fa :=_afg .GetBitmap ();if _fa !=nil {return nil ,_b .Wrap (_fa ,_af ,"");};_afc .InverseData ();return _afc .ToImage (),nil ;};func (_eb *Decoder )DecodeNextPage ()([]byte ,error ){_eb ._ba ++;
_df :=_eb ._ba ;return _eb .decodePage (_df );};func (_ag *Decoder )DecodePageImage (pageNumber int )(_e .Image ,error ){const _db ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
_ad ,_ac :=_ag .decodePageImage (pageNumber );if _ac !=nil {return nil ,_b .Wrap (_ac ,_db ,"");};return _ad ,nil ;};func (_gbg *Decoder )PageNumber ()(int ,error ){const _da ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";
if _gbg ._a ==nil {return 0,_b .Error (_da ,"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 (_gbg ._a .NumberOfPages ),nil ;};type Decoder struct{_gaf *_ga .Reader ;
_a *_bc .Document ;_ba int ;_d Parameters ;};type Parameters struct{UnpaddedData bool ;Color _gb .Color ;};func Decode (input []byte ,parameters Parameters ,globals *_bc .Globals )(*Decoder ,error ){_gf :=_ga .NewReader (input );_ff ,_aae :=_bc .DecodeDocument (_gf ,globals );
if _aae !=nil {return nil ,_aae ;};return &Decoder {_gaf :_gf ,_a :_ff ,_d :parameters },nil ;};func (_dd *Decoder )decodePage (_acd int )([]byte ,error ){const _dg ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _acd < 0{return nil ,_b .Errorf (_dg ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_acd );
};if _acd > int (_dd ._a .NumberOfPages ){return nil ,_b .Errorf (_dg ,"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",_acd );
};_bag ,_acg :=_dd ._a .GetPage (_acd );if _acg !=nil {return nil ,_b .Wrap (_acg ,_dg ,"");};_f ,_acg :=_bag .GetBitmap ();if _acg !=nil {return nil ,_b .Wrap (_acg ,_dg ,"");};_f .InverseData ();if !_dd ._d .UnpaddedData {return _f .Data ,nil ;};return _f .GetUnpaddedData ();
};