From 8af9a0f9d9c3d2da863c84eeae2326ba458fe118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Tue, 11 Oct 2022 15:38:55 +0200 Subject: [PATCH] jxl: remove C-style casts --- src/imageformats/jxl.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/imageformats/jxl.cpp b/src/imageformats/jxl.cpp index 1832860..da2cd2e 100644 --- a/src/imageformats/jxl.cpp +++ b/src/imageformats/jxl.cpp @@ -63,7 +63,7 @@ bool QJpegXLHandler::canRead(QIODevice *device) return false; } - JxlSignature signature = JxlSignatureCheck((const uint8_t *)header.constData(), header.size()); + JxlSignature signature = JxlSignatureCheck(reinterpret_cast(header.constData()), header.size()); if (signature == JXL_SIG_CODESTREAM || signature == JXL_SIG_CONTAINER) { return true; } @@ -111,7 +111,7 @@ bool QJpegXLHandler::ensureDecoder() return false; } - JxlSignature signature = JxlSignatureCheck((const uint8_t *)m_rawData.constData(), m_rawData.size()); + JxlSignature signature = JxlSignatureCheck(reinterpret_cast(m_rawData.constData()), m_rawData.size()); if (signature != JXL_SIG_CODESTREAM && signature != JXL_SIG_CONTAINER) { m_parseState = ParseJpegXLError; return false; @@ -139,7 +139,7 @@ bool QJpegXLHandler::ensureDecoder() } } - if (JxlDecoderSetInput(m_decoder, (const uint8_t *)m_rawData.constData(), m_rawData.size()) != JXL_DEC_SUCCESS) { + if (JxlDecoderSetInput(m_decoder, reinterpret_cast(m_rawData.constData()), m_rawData.size()) != JXL_DEC_SUCCESS) { qWarning("ERROR: JxlDecoderSetInput failed"); m_parseState = ParseJpegXLError; return false; @@ -273,8 +273,12 @@ bool QJpegXLHandler::countALLFrames() size_t icc_size = 0; if (JxlDecoderGetICCProfileSize(m_decoder, &m_input_pixel_format, JXL_COLOR_PROFILE_TARGET_DATA, &icc_size) == JXL_DEC_SUCCESS) { if (icc_size > 0) { - QByteArray icc_data((int)icc_size, 0); - if (JxlDecoderGetColorAsICCProfile(m_decoder, &m_input_pixel_format, JXL_COLOR_PROFILE_TARGET_DATA, (uint8_t *)icc_data.data(), icc_data.size()) + QByteArray icc_data(icc_size, 0); + if (JxlDecoderGetColorAsICCProfile(m_decoder, + &m_input_pixel_format, + JXL_COLOR_PROFILE_TARGET_DATA, + reinterpret_cast(icc_data.data()), + icc_data.size()) == JXL_DEC_SUCCESS) { m_colorspace = QColorSpace::fromIccProfile(icc_data); @@ -609,7 +613,7 @@ bool QJpegXLHandler::write(const QImage &image) } if (!convert_color_profile && iccprofile.size() > 0) { - status = JxlEncoderSetICCProfile(encoder, (const uint8_t *)iccprofile.constData(), iccprofile.size()); + status = JxlEncoderSetICCProfile(encoder, reinterpret_cast(iccprofile.constData()), iccprofile.size()); if (status != JXL_ENC_SUCCESS) { qWarning("JxlEncoderSetICCProfile failed!"); if (runner) { @@ -648,7 +652,7 @@ bool QJpegXLHandler::write(const QImage &image) #endif if (image.hasAlphaChannel() || ((save_depth == 8) && (xsize % 4 == 0))) { - status = JxlEncoderAddImageFrame(encoder_options, &pixel_format, (void *)tmpimage.constBits(), buffer_size); + status = JxlEncoderAddImageFrame(encoder_options, &pixel_format, static_cast(tmpimage.constBits()), buffer_size); } else { if (save_depth > 8) { // 16bit depth without alpha channel uint16_t *tmp_buffer = new (std::nothrow) uint16_t[3 * xsize * ysize]; @@ -679,7 +683,7 @@ bool QJpegXLHandler::write(const QImage &image) src_pixels += 2; // skipalpha } } - status = JxlEncoderAddImageFrame(encoder_options, &pixel_format, (void *)tmp_buffer, buffer_size); + status = JxlEncoderAddImageFrame(encoder_options, &pixel_format, static_cast(tmp_buffer), buffer_size); delete[] tmp_buffer; } else { // 8bit depth without alpha channel uchar *tmp_buffer8 = new (std::nothrow) uchar[3 * xsize * ysize]; @@ -698,7 +702,7 @@ bool QJpegXLHandler::write(const QImage &image) memcpy(dest_pixels8, tmpimage.constScanLine(y), rowbytes); dest_pixels8 += rowbytes; } - status = JxlEncoderAddImageFrame(encoder_options, &pixel_format, (void *)tmp_buffer8, buffer_size); + status = JxlEncoderAddImageFrame(encoder_options, &pixel_format, static_cast(tmp_buffer8), buffer_size); delete[] tmp_buffer8; } } @@ -930,7 +934,7 @@ bool QJpegXLHandler::rewind() } } - if (JxlDecoderSetInput(m_decoder, (const uint8_t *)m_rawData.constData(), m_rawData.size()) != JXL_DEC_SUCCESS) { + if (JxlDecoderSetInput(m_decoder, reinterpret_cast(m_rawData.constData()), m_rawData.size()) != JXL_DEC_SUCCESS) { qWarning("ERROR: JxlDecoderSetInput failed"); m_parseState = ParseJpegXLError; return false;