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 (_d "github.com/unidoc/unipdf/v3/internal/bitwise";_eb "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_f "github.com/unidoc/unipdf/v3/internal/jbig2/document";_b "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_c "image";
|
|
);type Decoder struct{_bc _d .StreamReader ;_a *_f .Document ;_eg int ;_aa Parameters ;};type Parameters struct{UnpaddedData bool ;Color _eb .Color ;};func (_ddc *Decoder )decodePageImage (_fac int )(_c .Image ,error ){const _ef ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
if _fac < 0{return nil ,_b .Errorf (_ef ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_fac );};if _fac > int (_ddc ._a .NumberOfPages ){return nil ,_b .Errorf (_ef ,"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",_fac );
|
|
};_ddca ,_fe :=_ddc ._a .GetPage (_fac );if _fe !=nil {return nil ,_b .Wrap (_fe ,_ef ,"");};_bac ,_fe :=_ddca .GetBitmap ();if _fe !=nil {return nil ,_b .Wrap (_fe ,_ef ,"");};_bac .InverseData ();return _bac .ToImage (),nil ;};func (_ba *Decoder )DecodePageImage (pageNumber int )(_c .Image ,error ){const _ebc ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
_ee ,_bcd :=_ba .decodePageImage (pageNumber );if _bcd !=nil {return nil ,_b .Wrap (_bcd ,_ebc ,"");};return _ee ,nil ;};func Decode (input []byte ,parameters Parameters ,globals *_f .Globals )(*Decoder ,error ){_ga :=_d .NewReader (input );_gaf ,_be :=_f .DecodeDocument (_ga ,globals );
|
|
if _be !=nil {return nil ,_be ;};return &Decoder {_bc :_ga ,_a :_gaf ,_aa :parameters },nil ;};func (_dbb *Decoder )PageNumber ()(int ,error ){const _fc ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";if _dbb ._a ==nil {return 0,_b .Error (_fc ,"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 (_dbb ._a .NumberOfPages ),nil ;};func (_ac *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _ac .decodePage (pageNumber )};func (_ad *Decoder )DecodeNextPage ()([]byte ,error ){_ad ._eg ++;_db :=_ad ._eg ;return _ad .decodePage (_db );
|
|
};func (_dd *Decoder )decodePage (_g int )([]byte ,error ){const _bcg ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _g < 0{return nil ,_b .Errorf (_bcg ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_g );
|
|
};if _g > int (_dd ._a .NumberOfPages ){return nil ,_b .Errorf (_bcg ,"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",_g );
|
|
};_ag ,_cg :=_dd ._a .GetPage (_g );if _cg !=nil {return nil ,_b .Wrap (_cg ,_bcg ,"");};_fa ,_cg :=_ag .GetBitmap ();if _cg !=nil {return nil ,_b .Wrap (_cg ,_bcg ,"");};_fa .InverseData ();if !_dd ._aa .UnpaddedData {return _fa .Data ,nil ;};return _fa .GetUnpaddedData ();
|
|
}; |