mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kimgio: jpeg and raw plugins review
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7995231b45
commit
6e1cca0022
3 changed files with 10 additions and 10 deletions
|
@ -1,3 +1,3 @@
|
|||
Sirtaj Singh Kang <taj@kde.org> -- kimgio and krl readers
|
||||
Antonio Larossa <larossa@kde.org> -- initial version of KRL reader
|
||||
Ivailo Monev <xakepa10@gmail.com> -- magick plugin
|
||||
Ivailo Monev <xakepa10@gmail.com> -- magick, raw and jpeg plugins
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
static const char* const s_jpegpluginformat = "jpg";
|
||||
|
||||
static const ushort s_peekbuffsize = 32;
|
||||
static const TJPF s_jpegpixelformat = TJPF_ARGB;
|
||||
// for reference:
|
||||
// https://en.wikipedia.org/wiki/List_of_file_signatures
|
||||
static const uchar s_jpgjfifheader[] = { 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01 };
|
||||
|
@ -64,7 +65,7 @@ bool JPEGHandler::canRead() const
|
|||
|
||||
bool JPEGHandler::read(QImage *image)
|
||||
{
|
||||
QByteArray data = device()->readAll();
|
||||
const QByteArray data = device()->readAll();
|
||||
|
||||
tjhandle jpegdecomp = tjInitDecompress();
|
||||
if (!jpegdecomp) {
|
||||
|
@ -88,8 +89,7 @@ bool JPEGHandler::read(QImage *image)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int s_jpegpixelFormat = TJPF_ARGB;
|
||||
int jpegbuffersize = (jpegwidth * jpegheight * tjPixelSize[s_jpegpixelFormat]);
|
||||
int jpegbuffersize = (jpegwidth * jpegheight * tjPixelSize[s_jpegpixelformat]);
|
||||
unsigned char *jpegbuffer = tjAlloc(jpegbuffersize);
|
||||
if (!jpegbuffer) {
|
||||
kWarning() << "Could not allocate buffer" << tjGetErrorStr2(jpegdecomp);
|
||||
|
@ -102,7 +102,7 @@ bool JPEGHandler::read(QImage *image)
|
|||
reinterpret_cast<const uchar*>(data.constData()), data.size(),
|
||||
jpegbuffer,
|
||||
jpegwidth, 0 , jpegheight,
|
||||
s_jpegpixelFormat,
|
||||
s_jpegpixelformat,
|
||||
TJFLAG_FASTDCT
|
||||
);
|
||||
if (jpegstatus != 0) {
|
||||
|
|
|
@ -58,28 +58,28 @@ bool RAWHandler::read(QImage *image)
|
|||
|
||||
int rawresult = raw.open_buffer(data.data(), data.size());
|
||||
if (rawresult != LIBRAW_SUCCESS) {
|
||||
kWarning() << libraw_strerror(rawresult);
|
||||
kWarning() << "Could not open buffer" << libraw_strerror(rawresult);
|
||||
raw.recycle();
|
||||
return false;
|
||||
}
|
||||
|
||||
rawresult = raw.unpack();
|
||||
if (rawresult != LIBRAW_SUCCESS) {
|
||||
kWarning() << libraw_strerror(rawresult);
|
||||
kWarning() << "Could not unpack" << libraw_strerror(rawresult);
|
||||
raw.recycle();
|
||||
return false;
|
||||
}
|
||||
|
||||
rawresult = raw.dcraw_process();
|
||||
if (rawresult != LIBRAW_SUCCESS) {
|
||||
kWarning() << libraw_strerror(rawresult);
|
||||
kWarning() << "Could not process" << libraw_strerror(rawresult);
|
||||
raw.recycle();
|
||||
return false;
|
||||
}
|
||||
|
||||
libraw_processed_image_t* rawimg = raw.dcraw_make_mem_image(&rawresult);
|
||||
if (!rawimg || rawresult != LIBRAW_SUCCESS) {
|
||||
kWarning() << libraw_strerror(rawresult);
|
||||
kWarning() << "Could not make image" << libraw_strerror(rawresult);
|
||||
raw.recycle();
|
||||
return false;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ bool RAWHandler::canRead(QIODevice *device)
|
|||
raw.recycle();
|
||||
return false;
|
||||
} else if (rawresult != LIBRAW_SUCCESS) {
|
||||
kWarning() << libraw_strerror(rawresult);
|
||||
kWarning() << "Could not open buffer" << libraw_strerror(rawresult);
|
||||
raw.recycle();
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue