// // 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 sampling ;import (_f "github.com/unidoc/unipdf/v3/internal/bitwise";_fa "github.com/unidoc/unipdf/v3/internal/imageutil";_c "io";);type Reader struct{_ge _fa .ImageBase ;_fg *_f .Reader ;_e ,_gb ,_d int ;_cf bool ;};func NewWriter (img _fa .ImageBase )*Writer {return &Writer {_bga :_f .NewWriterMSB (img .Data ),_bf :img ,_eda :img .ColorComponents ,_efe :img .BytesPerLine *8!=img .ColorComponents *img .BitsPerComponent *img .Width }; };func (_ee *Reader )ReadSamples (samples []uint32 )(_ca error ){for _gf :=0;_gf < len (samples );_gf ++{samples [_gf ],_ca =_ee .ReadSample ();if _ca !=nil {return _ca ;};};return nil ;};type SampleWriter interface{WriteSample (_dd uint32 )error ;WriteSamples (_ece []uint32 )error ; };func (_fgd *Reader )ReadSample ()(uint32 ,error ){if _fgd ._gb ==_fgd ._ge .Height {return 0,_c .EOF ;};_ad ,_da :=_fgd ._fg .ReadBits (byte (_fgd ._ge .BitsPerComponent ));if _da !=nil {return 0,_da ;};_fgd ._d --;if _fgd ._d ==0{_fgd ._d =_fgd ._ge .ColorComponents ; _fgd ._e ++;};if _fgd ._e ==_fgd ._ge .Width {if _fgd ._cf {_fgd ._fg .ConsumeRemainingBits ();};_fgd ._e =0;_fgd ._gb ++;};return uint32 (_ad ),nil ;};func ResampleBytes (data []byte ,bitsPerSample int )[]uint32 {var _dad []uint32 ;_b :=bitsPerSample ; var _adg uint32 ;var _fd byte ;_bd :=0;_ba :=0;_ef :=0;for _ef < len (data ){if _bd > 0{_dg :=_bd ;if _b < _dg {_dg =_b ;};_adg =(_adg <>uint (8-_dg ));_bd -=_dg ;if _bd > 0{_fd =_fd <>uint (_bd ));if _ed < 8{_fd =_be <=bitsPerSample {_bg :=_bd ;if _b < _bg {_bg =_b ;};_adg =(_adg <>uint (8-_bg ));_bd -=_bg ;if _bd > 0{_fd =_fd < 0{_cgg :=_fb ;if _cg < _cgg {_cgg =_cg ;};_ec =(_ec <>uint (bitsPerInputSample -_cgg ));_fb -=_cgg ;if _fb > 0{_baa =_baa <>uint (_fb )); if _ga < bitsPerInputSample {_baa =_ae <=bitsPerOutputSample {_eeb :=_fb ;if _cg < _eeb {_eeb =_cg ;};_ec =(_ec <>uint (bitsPerInputSample -_eeb )); _fb -=_eeb ;if _fb > 0{_baa =_baa < 0&&_cg < bitsPerOutputSample {_ec <<=uint (_cg );_bb =append (_bb ,_ec );};return _bb ; };func NewReader (img _fa .ImageBase )*Reader {return &Reader {_fg :_f .NewReader (img .Data ),_ge :img ,_d :img .ColorComponents ,_cf :img .BytesPerLine *8!=img .ColorComponents *img .BitsPerComponent *img .Width };};