mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
22 lines
3.6 KiB
Go
22 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";_g "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_gb "github.com/unidoc/unipdf/v3/internal/jbig2/document";_ga "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_cb "image";
|
|
);type Parameters struct{UnpaddedData bool ;Color _g .Color ;};func (_ca *Decoder )PageNumber ()(int ,error ){const _ff ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _ca ._ge ==nil {return 0,_ga .Error (_ff ,"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 (_ca ._ge .NumberOfPages ),nil ;};func Decode (input []byte ,parameters Parameters ,globals *_gb .Globals )(*Decoder ,error ){_gc :=_b .NewReader (input );_de ,_gd :=_gb .DecodeDocument (_gc ,globals );if _gd !=nil {return nil ,_gd ;};return &Decoder {_cg :_gc ,_ge :_de ,_eb :parameters },nil ;
|
|
};func (_bf *Decoder )DecodeNextPage ()([]byte ,error ){_bf ._e ++;_gf :=_bf ._e ;return _bf .decodePage (_gf );};func (_ba *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _ba .decodePage (pageNumber )};func (_f *Decoder )DecodePageImage (pageNumber int )(_cb .Image ,error ){const _ef ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
_d ,_db :=_f .decodePageImage (pageNumber );if _db !=nil {return nil ,_ga .Wrap (_db ,_ef ,"");};return _d ,nil ;};func (_ed *Decoder )decodePage (_ee int )([]byte ,error ){const _dd ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _ee < 0{return nil ,_ga .Errorf (_dd ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ee );
|
|
};if _ee > int (_ed ._ge .NumberOfPages ){return nil ,_ga .Errorf (_dd ,"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",_ee );
|
|
};_fd ,_dc :=_ed ._ge .GetPage (_ee );if _dc !=nil {return nil ,_ga .Wrap (_dc ,_dd ,"");};_cd ,_dc :=_fd .GetBitmap ();if _dc !=nil {return nil ,_ga .Wrap (_dc ,_dd ,"");};_cd .InverseData ();if !_ed ._eb .UnpaddedData {return _cd .Data ,nil ;};return _cd .GetUnpaddedData ();
|
|
};func (_dcc *Decoder )decodePageImage (_fe int )(_cb .Image ,error ){const _dbc ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";if _fe < 0{return nil ,_ga .Errorf (_dbc ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_fe );
|
|
};if _fe > int (_dcc ._ge .NumberOfPages ){return nil ,_ga .Errorf (_dbc ,"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",_fe );
|
|
};_fc ,_cbb :=_dcc ._ge .GetPage (_fe );if _cbb !=nil {return nil ,_ga .Wrap (_cbb ,_dbc ,"");};_ddg ,_cbb :=_fc .GetBitmap ();if _cbb !=nil {return nil ,_ga .Wrap (_cbb ,_dbc ,"");};_ddg .InverseData ();return _ddg .ToImage (),nil ;};type Decoder struct{_cg _b .StreamReader ;
|
|
_ge *_gb .Document ;_e int ;_eb Parameters ;}; |