mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-04 22:17:22 +08:00
23 lines
3.6 KiB
Go
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 (_c "github.com/unidoc/unipdf/v3/internal/bitwise";_cc "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_ba "github.com/unidoc/unipdf/v3/internal/jbig2/document";_ccc "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_d "image";
|
|
);func (_dd *Decoder )decodePageImage (_eg int )(_d .Image ,error ){const _gf ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _eg < 0{return nil ,_ccc .Errorf (_gf ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_eg );
|
|
};if _eg > int (_dd ._cca .NumberOfPages ){return nil ,_ccc .Errorf (_gf ,"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",_eg );
|
|
};_fc ,_ae :=_dd ._cca .GetPage (_eg );if _ae !=nil {return nil ,_ccc .Wrap (_ae ,_gf ,"");};_af ,_ae :=_fc .GetBitmap ();if _ae !=nil {return nil ,_ccc .Wrap (_ae ,_gf ,"");};_af .InverseData ();return _af .ToImage (),nil ;};func (_ca *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _ca .decodePage (pageNumber )};
|
|
func Decode (input []byte ,parameters Parameters ,globals *_ba .Globals )(*Decoder ,error ){_egc :=_c .NewReader (input );_ege ,_aea :=_ba .DecodeDocument (_egc ,globals );if _aea !=nil {return nil ,_aea ;};return &Decoder {_bb :_egc ,_cca :_ege ,_bag :parameters },nil ;
|
|
};func (_f *Decoder )DecodePageImage (pageNumber int )(_d .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";_fa ,_de :=_f .decodePageImage (pageNumber );
|
|
if _de !=nil {return nil ,_ccc .Wrap (_de ,_cb ,"");};return _fa ,nil ;};func (_gdd *Decoder )decodePage (_ac int )([]byte ,error ){const _gb ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _ac < 0{return nil ,_ccc .Errorf (_gb ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ac );
|
|
};if _ac > int (_gdd ._cca .NumberOfPages ){return nil ,_ccc .Errorf (_gb ,"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",_ac );
|
|
};_eb ,_be :=_gdd ._cca .GetPage (_ac );if _be !=nil {return nil ,_ccc .Wrap (_be ,_gb ,"");};_bg ,_be :=_eb .GetBitmap ();if _be !=nil {return nil ,_ccc .Wrap (_be ,_gb ,"");};_bg .InverseData ();if !_gdd ._bag .UnpaddedData {return _bg .Data ,nil ;};
|
|
return _bg .GetUnpaddedData ();};type Decoder struct{_bb _c .StreamReader ;_cca *_ba .Document ;_df int ;_bag Parameters ;};func (_gd *Decoder )PageNumber ()(int ,error ){const _e ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";
|
|
if _gd ._cca ==nil {return 0,_ccc .Error (_e ,"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 (_gd ._cca .NumberOfPages ),nil ;};type Parameters struct{UnpaddedData bool ;
|
|
Color _cc .Color ;};func (_a *Decoder )DecodeNextPage ()([]byte ,error ){_a ._df ++;_g :=_a ._df ;return _a .decodePage (_g )}; |