[gs-commits] mupdf 1.16.1.75 Update fz_stream/fz_output with float rea
[email protected] (Robin Watts) Thu, 3 Oct 2019 15:19:03 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 9f46b6876806d2059e544a832bcbcabdb4a330c3 Author: Robin Watts <[email protected]> Date: Wed Oct 2 17:47:11 2019 +0100 Update fz_stream/fz_output with float reading/writing functions. diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h index abd51b8..ea23c31 100644 --- a/include/mupdf/fitz/output.h +++ b/include/mupdf/fitz/output.h @@ -126,6 +126,8 @@ void fz_write_uint16_be(fz_context *ctx, fz_output *out, unsigned int x); void fz_write_uint16_le(fz_context *ctx, fz_output *out, unsigned int x); void fz_write_char(fz_context *ctx, fz_output *out, char x); void fz_write_byte(fz_context *ctx, fz_output *out, unsigned char x); +void fz_write_float_be(fz_context *ctx, fz_output *out, float f); +void fz_write_float_le(fz_context *ctx, fz_output *out, float f); void fz_write_rune(fz_context *ctx, fz_output *out, int rune); diff --git a/include/mupdf/fitz/stream.h b/include/mupdf/fitz/stream.h index acf6b28..76ffd99 100644 --- a/include/mupdf/fitz/stream.h +++ b/include/mupdf/fitz/stream.h @@ -60,6 +60,9 @@ int16_t fz_read_int16_le(fz_context *ctx, fz_stream *stm); int32_t fz_read_int32_le(fz_context *ctx, fz_stream *stm); int64_t fz_read_int64_le(fz_context *ctx, fz_stream *stm); +float fz_read_float_le(fz_context *ctx, fz_stream *stm); +float fz_read_float(fz_context *ctx, fz_stream *stm); + void fz_read_string(fz_context *ctx, fz_stream *stm, char *buffer, int len); /* diff --git a/source/fitz/output.c b/source/fitz/output.c index cdbd315..5964dce 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -519,6 +519,21 @@ fz_write_uint16_le(fz_context *ctx, fz_output *out, unsigned int x) fz_write_int16_le(ctx, out, (int)x); } +void +fz_write_float_le(fz_context *ctx, fz_output *out, float f) +{ + union {float f; int32_t i;} u; + u.f = f; + fz_write_int32_le(ctx, out, u.i); +} + +void +fz_write_float_be(fz_context *ctx, fz_output *out, float f) +{ + union {float f; int32_t i;} u; + u.f = f; + fz_write_int32_be(ctx, out, u.i); +} /* Write a UTF-8 encoded unicode character. diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c index dcb42e0..947b593 100644 --- a/source/fitz/stream-read.c +++ b/source/fitz/stream-read.c @@ -374,6 +374,25 @@ int16_t fz_read_int16_le(fz_context *ctx, fz_stream *stm) { return (int16_t)fz_r int32_t fz_read_int32_le(fz_context *ctx, fz_stream *stm) { return (int32_t)fz_read_uint32_le(ctx, stm); } int64_t fz_read_int64_le(fz_context *ctx, fz_stream *stm) { return (int64_t)fz_read_uint64_le(ctx, stm); } +float +fz_read_float_le(fz_context *ctx, fz_stream *stm) +{ + union {float f;int32_t i;} u; + + u.i = fz_read_int32_le(ctx, stm); + return u.f; +} + +float +fz_read_float(fz_context *ctx, fz_stream *stm) +{ + union {float f;int32_t i;} u; + + u.i = fz_read_int32(ctx, stm); + return u.f; +} + + /* Read a null terminated string from the stream into a buffer of a given length. The buffer will be null terminated. http://git.ghostscript.com/?p=mupdf.git;a=commit;h=9f46b6876806d2059e544a832bcbcabdb4a330c3 -- MuPDF library Artifex Software, Inc.