Skip to content

Commit

Permalink
fix windows?
Browse files Browse the repository at this point in the history
  • Loading branch information
chearon committed Nov 16, 2024
1 parent 77f0b99 commit 402f809
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,7 @@ class BufferReader : public Image::Reader {
bool hasBytes(unsigned n) const override { return (_idx + n - 1 < _len); }

uint8_t getNext() override {
if (_idx < _len) {
return _buf[_idx++];
}
return _buf[_idx++];
}

void skipBytes(unsigned n) override { _idx += n; }
Expand All @@ -789,9 +787,9 @@ class BufferReader : public Image::Reader {
class StreamReader : public Image::Reader {
public:
StreamReader(FILE *stream) : _stream(stream), _len(0), _idx(0) {
fseeko(_stream, 0, SEEK_END);
_len = ftello(_stream);
fseeko(_stream, 0, SEEK_SET);
fseek(_stream, 0, SEEK_END);
_len = ftell(_stream);
fseek(_stream, 0, SEEK_SET);
}

bool hasBytes(unsigned n) const override { return (_idx + n - 1 < _len); }
Expand All @@ -803,13 +801,13 @@ class StreamReader : public Image::Reader {

void skipBytes(unsigned n) override {
_idx += n;
fseeko(_stream, _idx, SEEK_SET);
fseek(_stream, _idx, SEEK_SET);
}

private:
FILE* _stream;
off_t _len;
off_t _idx;
unsigned _len;
unsigned _idx;
};

void Image::jpegToARGB(jpeg_decompress_struct* args, uint8_t* data, uint8_t* src, JPEGDecodeL decode) {
Expand Down

0 comments on commit 402f809

Please sign in to comment.