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";_f "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_b "github.com/unidoc/unipdf/v3/internal/jbig2/document";_a "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_e "image";
|
|
);func (_af *Decoder )decodePage (_ge int )([]byte ,error ){const _ad ="\u0064\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065";if _ge < 0{return nil ,_a .Errorf (_ad ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_ge );
|
|
};if _ge > int (_af ._c .NumberOfPages ){return nil ,_a .Errorf (_ad ,"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",_ge );
|
|
};_gef ,_ee :=_af ._c .GetPage (_ge );if _ee !=nil {return nil ,_a .Wrap (_ee ,_ad ,"");};_eef ,_ee :=_gef .GetBitmap ();if _ee !=nil {return nil ,_a .Wrap (_ee ,_ad ,"");};_eef .InverseData ();if !_af ._bg .UnpaddedData {return _eef .Data ,nil ;};return _eef .GetUnpaddedData ();
|
|
};func (_ab *Decoder )DecodePage (pageNumber int )([]byte ,error ){return _ab .decodePage (pageNumber )};func (_dd *Decoder )PageNumber ()(int ,error ){const _df ="\u0044e\u0063o\u0064\u0065\u0072\u002e\u0050a\u0067\u0065N\u0075\u006d\u0062\u0065\u0072";
|
|
if _dd ._c ==nil {return 0,_a .Error (_df ,"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 (_dd ._c .NumberOfPages ),nil ;};func (_bd *Decoder )decodePageImage (_eeb int )(_e .Image ,error ){const _fd ="\u0064e\u0063o\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
if _eeb < 0{return nil ,_a .Errorf (_fd ,"\u0069n\u0076\u0061\u006c\u0069d\u0020\u0070\u0061\u0067\u0065 \u006eu\u006db\u0065\u0072\u003a\u0020\u0027\u0025\u0064'",_eeb );};if _eeb > int (_bd ._c .NumberOfPages ){return nil ,_a .Errorf (_fd ,"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",_eeb );
|
|
};_ggd ,_adc :=_bd ._c .GetPage (_eeb );if _adc !=nil {return nil ,_a .Wrap (_adc ,_fd ,"");};_dg ,_adc :=_ggd .GetBitmap ();if _adc !=nil {return nil ,_a .Wrap (_adc ,_fd ,"");};_dg .InverseData ();return _dg .ToImage (),nil ;};func (_de *Decoder )DecodeNextPage ()([]byte ,error ){_de ._eg ++;
|
|
_be :=_de ._eg ;return _de .decodePage (_be );};func Decode (input []byte ,parameters Parameters ,globals *_b .Globals )(*Decoder ,error ){_gbe :=_d .NewReader (input );_cb ,_gf :=_b .DecodeDocument (_gbe ,globals );if _gf !=nil {return nil ,_gf ;};return &Decoder {_gg :_gbe ,_c :_cb ,_bg :parameters },nil ;
|
|
};type Decoder struct{_gg _d .StreamReader ;_c *_b .Document ;_eg int ;_bg Parameters ;};type Parameters struct{UnpaddedData bool ;Color _f .Color ;};func (_abf *Decoder )DecodePageImage (pageNumber int )(_e .Image ,error ){const _gb ="\u0064\u0065\u0063od\u0065\u0072\u002e\u0044\u0065\u0063\u006f\u0064\u0065\u0050\u0061\u0067\u0065\u0049\u006d\u0061\u0067\u0065";
|
|
_bb ,_bc :=_abf .decodePageImage (pageNumber );if _bc !=nil {return nil ,_a .Wrap (_bc ,_gb ,"");};return _bb ,nil ;}; |