Create zlib_set_stream
This commit is contained in:
parent
758d01b5da
commit
5d776f15b6
|
@ -349,10 +349,12 @@ bool zlib_inflate_data_to_file_init(
|
||||||
if (!stream)
|
if (!stream)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
stream->next_in = (uint8_t*)cdata;
|
zlib_set_stream(stream,
|
||||||
stream->avail_in = csize;
|
csize,
|
||||||
stream->next_out = handle->data;
|
size,
|
||||||
stream->avail_out = size;
|
(const uint8_t*)cdata,
|
||||||
|
handle->data
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -778,3 +780,22 @@ bool zlib_perform_mode(const char *path, const char *valid_exts,
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void zlib_set_stream(void *data,
|
||||||
|
uint32_t avail_in,
|
||||||
|
uint32_t avail_out,
|
||||||
|
const uint8_t *next_in,
|
||||||
|
uint8_t *next_out
|
||||||
|
)
|
||||||
|
{
|
||||||
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
|
if (!stream)
|
||||||
|
return;
|
||||||
|
|
||||||
|
stream->avail_in = avail_in;
|
||||||
|
stream->avail_out = avail_out;
|
||||||
|
|
||||||
|
stream->next_in = (uint8_t*)next_in;
|
||||||
|
stream->next_out = next_out;
|
||||||
|
}
|
||||||
|
|
|
@ -655,10 +655,12 @@ bool rpng_load_image_argb_process_init(struct rpng_t *rpng,
|
||||||
if (!rpng->process.inflate_buf)
|
if (!rpng->process.inflate_buf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
rpng->process.stream.next_in = rpng->idat_buf.data;
|
zlib_set_stream(
|
||||||
rpng->process.stream.avail_in = rpng->idat_buf.size;
|
&rpng->process.stream,
|
||||||
rpng->process.stream.avail_out = rpng->process.inflate_buf_size;
|
rpng->idat_buf.size,
|
||||||
rpng->process.stream.next_out = rpng->process.inflate_buf;
|
rpng->process.inflate_buf_size,
|
||||||
|
rpng->idat_buf.data,
|
||||||
|
rpng->process.inflate_buf);
|
||||||
|
|
||||||
rpng->process.initialized = true;
|
rpng->process.initialized = true;
|
||||||
|
|
||||||
|
|
|
@ -310,10 +310,12 @@ static bool rpng_save_image(const char *path,
|
||||||
if (!deflate_buf)
|
if (!deflate_buf)
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
stream.next_in = encode_buf;
|
zlib_set_stream(
|
||||||
stream.avail_in = encode_buf_size;
|
&stream,
|
||||||
stream.next_out = deflate_buf + 8;
|
encode_buf_size,
|
||||||
stream.avail_out = encode_buf_size * 2;
|
encode_buf_size * 2,
|
||||||
|
encode_buf,
|
||||||
|
deflate_buf + 8);
|
||||||
|
|
||||||
deflateInit(&stream, 9);
|
deflateInit(&stream, 9);
|
||||||
if (deflate(&stream, Z_FINISH) != Z_STREAM_END)
|
if (deflate(&stream, Z_FINISH) != Z_STREAM_END)
|
||||||
|
|
|
@ -121,5 +121,12 @@ bool zlib_inflate_init(void *data);
|
||||||
|
|
||||||
bool zlib_inflate_init2(void *data);
|
bool zlib_inflate_init2(void *data);
|
||||||
|
|
||||||
|
void zlib_set_stream(void *data,
|
||||||
|
uint32_t avail_in,
|
||||||
|
uint32_t avail_out,
|
||||||
|
const uint8_t *next_in,
|
||||||
|
uint8_t *next_out
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue