Skip to content

Commit

Permalink
Sync
Browse files Browse the repository at this point in the history
Sync more upstream changes, etc.
  • Loading branch information
sdneon committed May 22, 2024
1 parent e9ae6fb commit f405cc3
Show file tree
Hide file tree
Showing 30 changed files with 3,320 additions and 269 deletions.
32 changes: 31 additions & 1 deletion src/JPEGView/Config/JPEGView-fullscreen.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ FilesProcessedByWIC=*.wdp;*.hdp;*.jxr;*.ico

; File endings of camera RAW files to be searched for embedded JPEG thumb images to display
; Reading just these embedded JPEGs is much faster than decoding the RAW using WIC
FileEndingsRAW=*.pef;*.dng;*.crw;*.nef;*.cr2;*.mrw;*.rw2;*.orf;*.x3f;*.arw;*.kdc;*.nrw;*.dcr;*.sr2;*.raf
FileEndingsRAW=*.pef;*.dng;*.crw;*.nef;*.cr2;*.mrw;*.rw2;*.orf;*.x3f;*.arw;*.kdc;*.nrw;*.dcr;*.sr2;*.raf;*.kc2;*.erf;*.3fr;*.raw;*.mef;*.mos;*.mdc;*.cr3

; Set behavior for opening RAW files listed in FileEndingsRAW
; 0: open embedded thumbnail
; 1: open full size
; 2: open thumbnail, fallback to full size
; 3: open full size, fallback to thumbnail
DisplayFullSizeRAW=0

; If true, reloads the currently displayed image automatically when it is changed by an external program on disk.
; Also reloads the image list when a file in the current directory is added or deleted.
Expand All @@ -75,6 +82,20 @@ FileNameColor=255 255 255
; Example: DefaultGUIFont="Arial" 9.0 bold
DefaultGUIFont=Default


; -----------------------------------------------
; - WINDOW BEHAVIOR OPTIONS
; -----------------------------------------------

; If set to 'true', window starts in always-on-top mode (window will always be visible on top of other windows)
; The window mode can be changed after startup
WindowAlwaysOnTopOnStartup=false


; -----------------------------------------------
; - ADVANCED IMAGE CORRECTION PARAMETERS
; -----------------------------------------------

; Contrast correction to apply to all images. Must be in -0.5 .. 0.5
; Values > 0 increase contrast, values < 0 decrease contrast
Contrast=0.0
Expand All @@ -91,6 +112,14 @@ Saturation=1.0
; Note that for 100 % zoom, the BestQuality filter will not apply any sharpening, only the other filters do
Sharpen=0.3



; *****************************************************************************
; * DEFAULT IMAGE EDITING OPTIONS
; *
; * These options are related to JPEGView defaults for image editing
; *****************************************************************************

; Default parameters for unsharp masking: Radius Amount Threshold
; Note that no unsharp masking can be applied automatically to every image - this setting only provides the default parameters
; when entering the unsharp mask mode
Expand Down Expand Up @@ -228,6 +257,7 @@ IsSortedUpcounting=true
; LoopFolder : Loop within the source folder and never leave this folder
; LoopSameFolderLevel: Loop to next folder on the same hierarchy level (sibling folders)
; LoopSubFolders: Loop into subfolders of the source folder
; Auto: Auto-choose LoopSubFolders (if initial folder has subfolder) or LoopSameFolderLevel (otherwise)
FolderNavigation=LoopSubFolders

; If true, the mouse wheel can be used to navigate forward and backward and zoom must be done with Ctrl-MouseWheel
Expand Down
32 changes: 31 additions & 1 deletion src/JPEGView/Config/JPEGView-windowed.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ FilesProcessedByWIC=*.wdp;*.hdp;*.jxr;*.ico

; File endings of camera RAW files to be searched for embedded JPEG thumb images to display
; Reading just these embedded JPEGs is much faster than decoding the RAW using WIC
FileEndingsRAW=*.pef;*.dng;*.crw;*.nef;*.cr2;*.mrw;*.rw2;*.orf;*.x3f;*.arw;*.kdc;*.nrw;*.dcr;*.sr2;*.raf
FileEndingsRAW=*.pef;*.dng;*.crw;*.nef;*.cr2;*.mrw;*.rw2;*.orf;*.x3f;*.arw;*.kdc;*.nrw;*.dcr;*.sr2;*.raf;*.kc2;*.erf;*.3fr;*.raw;*.mef;*.mos;*.mdc;*.cr3

; Set behavior for opening RAW files listed in FileEndingsRAW
; 0: open embedded thumbnail
; 1: open full size
; 2: open thumbnail, fallback to full size
; 3: open full size, fallback to thumbnail
DisplayFullSizeRAW=0

; If true, reloads the currently displayed image automatically when it is changed by an external program on disk.
; Also reloads the image list when a file in the current directory is added or deleted.
Expand All @@ -75,6 +82,20 @@ FileNameColor=255 255 255
; Example: DefaultGUIFont="Arial" 9.0 bold
DefaultGUIFont=Default


; -----------------------------------------------
; - WINDOW BEHAVIOR OPTIONS
; -----------------------------------------------

; If set to 'true', window starts in always-on-top mode (window will always be visible on top of other windows)
; The window mode can be changed after startup
WindowAlwaysOnTopOnStartup=false


; -----------------------------------------------
; - ADVANCED IMAGE CORRECTION PARAMETERS
; -----------------------------------------------

; Contrast correction to apply to all images. Must be in -0.5 .. 0.5
; Values > 0 increase contrast, values < 0 decrease contrast
Contrast=0.0
Expand All @@ -91,6 +112,14 @@ Saturation=1.0
; Note that for 100 % zoom, the BestQuality filter will not apply any sharpening, only the other filters do
Sharpen=0.3



; *****************************************************************************
; * DEFAULT IMAGE EDITING OPTIONS
; *
; * These options are related to JPEGView defaults for image editing
; *****************************************************************************

; Default parameters for unsharp masking: Radius Amount Threshold
; Note that no unsharp masking can be applied automatically to every image - this setting only provides the default parameters
; when entering the unsharp mask mode
Expand Down Expand Up @@ -228,6 +257,7 @@ IsSortedUpcounting=true
; LoopFolder : Loop within the source folder and never leave this folder
; LoopSameFolderLevel: Loop to next folder on the same hierarchy level (sibling folders)
; LoopSubFolders: Loop into subfolders of the source folder
; Auto: Auto-choose LoopSubFolders (if initial folder has subfolder) or LoopSameFolderLevel (otherwise)
FolderNavigation=LoopSubFolders

; If true, the mouse wheel can be used to navigate forward and backward and zoom must be done with Ctrl-MouseWheel
Expand Down
70 changes: 21 additions & 49 deletions src/JPEGView/ImageLoadThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "JXLWrapper.h"
#include "HEIFWrapper.h"
#include "RAWWrapper.h"
#include "WEBPWrapper.h"
#include "QOIWrapper.h"
#include "PSDWrapper.h"
#include "MaxImageDef.h"
Expand Down Expand Up @@ -536,13 +537,7 @@ void CImageLoadThread::DeleteCachedGDIBitmap() {
}

void CImageLoadThread::DeleteCachedWebpDecoder() {
__declspec(dllimport) void Webp_Dll_AnimDecoderDelete();
// temporary fix to prevent crashing when webp.dll is not found
try {
Webp_Dll_AnimDecoderDelete();
} catch (...) {
;
}
WebpReaderWriter::DeleteCache();
m_sLastWebpFileName.Empty();
}

Expand Down Expand Up @@ -953,13 +948,6 @@ void CImageLoadThread::ProcessReadTGARequest(CRequest* request) {
}
}

__declspec(dllimport) int Webp_Dll_GetInfo(const uint8* data, size_t data_size, int* width, int* height);
__declspec(dllimport) int Webp_Dll_GetInfoCached(int& width, int& height);
__declspec(dllimport) bool Webp_Dll_HasAnimation(const uint8* data, uint32 data_size);
__declspec(dllimport) uint8* Webp_Dll_AnimDecodeBGRAInto(const uint8* data, uint32 data_size, uint8* output_buffer, int output_buffer_size, int& nFrameCount, int& nFrameTimeMs);
__declspec(dllimport) uint8* Webp_Dll_DecodeBGRInto(const uint8* data, uint32 data_size, uint8* output_buffer, int output_buffer_size, int output_stride);
__declspec(dllimport) uint8* Webp_Dll_DecodeBGRAInto(const uint8* data, uint32 data_size, uint8* output_buffer, int output_buffer_size, int output_stride);

void CImageLoadThread::ProcessReadWEBPRequest(CRequest* request) {
bool bUseCachedDecoder = false;
const wchar_t* sFileName;
Expand Down Expand Up @@ -1000,46 +988,30 @@ void CImageLoadThread::ProcessReadWEBPRequest(CRequest* request) {
}
if (bUseCachedDecoder || (::ReadFile(hFile, pBuffer, nFileSize, (LPDWORD)&nNumBytesRead, NULL) && nNumBytesRead == nFileSize)) {
int nWidth, nHeight;
if ((bUseCachedDecoder && Webp_Dll_GetInfoCached(nWidth, nHeight)) ||
(!bUseCachedDecoder && Webp_Dll_GetInfo((uint8*)pBuffer, nFileSize, &nWidth, &nHeight))) {
if (nWidth <= MAX_IMAGE_DIMENSION && nHeight <= MAX_IMAGE_DIMENSION) {
if ((double)nWidth * nHeight <= MAX_IMAGE_PIXELS) {
int nStride = nWidth * 4;
uint8* pPixelData = new(std::nothrow) unsigned char[nStride * nHeight];
if (pPixelData != NULL) {
bool bHasAnimation = bUseCachedDecoder || Webp_Dll_HasAnimation((uint8*)pBuffer, nFileSize);
if (bHasAnimation) {
m_sLastWebpFileName = sFileName;
}

int nFrameCount = 1;
int nFrameTimeMs = 0;
if ((bHasAnimation && Webp_Dll_AnimDecodeBGRAInto((uint8*)pBuffer, nFileSize, pPixelData, nStride * nHeight, nFrameCount, nFrameTimeMs)) ||
(!bHasAnimation && Webp_Dll_DecodeBGRAInto((uint8*)pBuffer, nFileSize, pPixelData, nStride * nHeight, nStride))) {
// Multiply alpha value into each AABBGGRR pixel
BlendAlpha((uint32*)pPixelData, nWidth, nHeight, request->ProcessParams.TransparencyMode);
request->Image = new CJPEGImage(nWidth, nHeight, pPixelData, NULL, 4, 0, IF_WEBP, bHasAnimation, request->FrameIndex, nFrameCount, nFrameTimeMs);
}
else {
delete[] pPixelData;
DeleteCachedWebpDecoder();
}
}
else {
request->OutOfMemory = true;
}
}
else {
request->OutOfMemory = true;
}
bool bHasAnimation = bUseCachedDecoder;
int nFrameCount = 1;
int nFrameTimeMs = 0;
int nBPP;
void* pEXIFData;
uint8* pPixelData = (uint8*)WebpReaderWriter::ReadImage(nWidth, nHeight, nBPP, bHasAnimation, nFrameCount, nFrameTimeMs, pEXIFData, request->OutOfMemory, pBuffer, nFileSize);
if (pPixelData && nBPP == 4) {
// Multiply alpha value into each AABBGGRR pixel
BlendAlpha((uint32*)pPixelData, nWidth, nHeight, request->ProcessParams.TransparencyMode);

if (bHasAnimation) {
m_sLastWebpFileName = sFileName;
}
request->Image = new CJPEGImage(nWidth, nHeight, pPixelData, pEXIFData, nBPP, 0, IF_WEBP, bHasAnimation, request->FrameIndex, nFrameCount, nFrameTimeMs);
free(pEXIFData);
}
else {
delete[] pPixelData;
DeleteCachedWebpDecoder();
}
}
}
catch (...) {
} catch (...) {
delete request->Image;
request->Image = NULL;
request->ExceptionError = true;
}
if (!bUseCachedDecoder) {
::CloseHandle(hFile);
Expand Down
Loading

0 comments on commit f405cc3

Please sign in to comment.