Skip to content

Commit

Permalink
Bugfix: K25 RAW decode processing
Browse files Browse the repository at this point in the history
K25 now uses dcraw first to show thumbnail if `DisplayFullsizeRaw=2`

Merge PR #311 by https://github.com/qbnu
  • Loading branch information
sylikc committed Jun 21, 2024
2 parents 5d67c64 + 49c97f2 commit 37479d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/JPEGView/ImageLoadThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,17 +1012,22 @@ void CImageLoadThread::ProcessReadRAWRequest(CRequest * request) {
if (fullsize == 2 || fullsize == 3) {
request->Image = RawReader::ReadImage(request->FileName, bOutOfMemory, fullsize == 2);
}
if (request->Image == NULL && fullsize == 2) {
request->Image = CReaderRAW::ReadRawImage(request->FileName, bOutOfMemory);
}
if (request->Image == NULL) {
request->Image = RawReader::ReadImage(request->FileName, bOutOfMemory, fullsize == 0 || fullsize == 3);
}
} catch (...) {
// libraw.dll not found or VC++ Runtime not installed
}
SetErrorMode(nPrevErrorMode);
#else
fullsize = fullsize == 1;
#endif

// Try with dcraw_mod
if (request->Image == NULL && fullsize != 1) {
if (request->Image == NULL && fullsize != 1 && fullsize != 2) {
request->Image = CReaderRAW::ReadRawImage(request->FileName, bOutOfMemory);
}
} catch (...) {
Expand Down
12 changes: 7 additions & 5 deletions src/JPEGView/RAWWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ CJPEGImage* RawReader::ReadImage(LPCTSTR strFileName, bool& bOutOfMemory, bool b

CJPEGImage* Image = NULL;
if (!bGetThumb) {
RawProcessor.get_mem_image_format(&width, &height, &colors, &bps);
RawProcessor.imgdata.params.output_bps = 8;

if (width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION) {
// Must unpack and process first to get accurate info
if (RawProcessor.unpack() != LIBRAW_SUCCESS || RawProcessor.dcraw_process() != LIBRAW_SUCCESS) {
return NULL;
}

if ((double)width * height > MAX_IMAGE_PIXELS) {
bOutOfMemory = true;
RawProcessor.get_mem_image_format(&width, &height, &colors, &bps);

if (width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION) {
return NULL;
}

if (RawProcessor.unpack() != LIBRAW_SUCCESS || RawProcessor.dcraw_process() != LIBRAW_SUCCESS) {
if ((double)width * height > MAX_IMAGE_PIXELS) {
bOutOfMemory = true;
return NULL;
}

Expand Down

0 comments on commit 37479d8

Please sign in to comment.