@@ -773,9 +773,7 @@ class BufferReader : public Image::Reader {
773773 bool hasBytes (unsigned n) const override { return (_idx + n - 1 < _len); }
774774
775775 uint8_t getNext () override {
776- if (_idx < _len) {
777- return _buf[_idx++];
778- }
776+ return _buf[_idx++];
779777 }
780778
781779 void skipBytes (unsigned n) override { _idx += n; }
@@ -789,9 +787,9 @@ class BufferReader : public Image::Reader {
789787class StreamReader : public Image ::Reader {
790788public:
791789 StreamReader (FILE *stream) : _stream(stream), _len(0 ), _idx(0 ) {
792- fseeko (_stream, 0 , SEEK_END);
793- _len = ftello (_stream);
794- fseeko (_stream, 0 , SEEK_SET);
790+ fseek (_stream, 0 , SEEK_END);
791+ _len = ftell (_stream);
792+ fseek (_stream, 0 , SEEK_SET);
795793 }
796794
797795 bool hasBytes (unsigned n) const override { return (_idx + n - 1 < _len); }
@@ -803,13 +801,13 @@ class StreamReader : public Image::Reader {
803801
804802 void skipBytes (unsigned n) override {
805803 _idx += n;
806- fseeko (_stream, _idx, SEEK_SET);
804+ fseek (_stream, _idx, SEEK_SET);
807805 }
808806
809807private:
810808 FILE* _stream;
811- off_t _len;
812- off_t _idx;
809+ unsigned _len;
810+ unsigned _idx;
813811};
814812
815813void Image::jpegToARGB (jpeg_decompress_struct* args, uint8_t * data, uint8_t * src, JPEGDecodeL decode) {
@@ -1289,8 +1287,12 @@ Image::getExifOrientation(Reader& jpeg) {
12891287 };
12901288 // The first two bytes of TIFF header are "II" if little-endian ("Intel")
12911289 // and "MM" if big-endian ("Motorola")
1292- auto readUint32 = (isLE ? readUint32Little : readUint32Big);
1293- auto readUint16 = (isLE ? readUint16Little : readUint16Big);
1290+ auto readUint32 = [readUint32Little, readUint32Big, isLE](Reader &jpeg) -> uint32_t {
1291+ return isLE ? readUint32Little (jpeg) : readUint32Big (jpeg);
1292+ };
1293+ auto readUint16 = [readUint16Little, readUint16Big, isLE](Reader &jpeg) -> uint32_t {
1294+ return isLE ? readUint16Little (jpeg) : readUint16Big (jpeg);
1295+ };
12941296 // offset to the IFD0 (offset from beginning of TIFF header, II/MM,
12951297 // which is 8 bytes before where we are after reading the uint32)
12961298 jpeg.skipBytes (readUint32 (jpeg) - 8 );
0 commit comments