Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ endif()

option(TEV_SUPPORT_HEIC "Support loading HEIC images" OFF)

set(TEV_USE_LIBHEIF ${TEV_SUPPORT_HEIC}) # If other codecs supported by heif are used, adjust this condition.

# Set ourselves as the startup project in visual studio.
# Not available until cmake 3.6, but doesn't break older versions.
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT tev)
Expand Down Expand Up @@ -150,8 +152,8 @@ set(TEV_LIBS clip OpenEXR::OpenEXR nanogui ${NANOGUI_EXTRA_LIBS})
if (MSVC)
set(TEV_LIBS ${TEV_LIBS} zlibstatic DirectXTex wsock32 ws2_32)
endif()
if (TEV_SUPPORT_HEIC)
set(TEV_LIBS ${TEV_LIBS} de265 heif)
if (TEV_USE_LIBHEIF)
set(TEV_LIBS ${TEV_LIBS} heif)
endif()

set(TEV_SOURCES
Expand Down Expand Up @@ -195,7 +197,7 @@ if (MSVC)
elseif (APPLE)
set(TEV_SOURCES ${TEV_SOURCES} resources/icon.icns scripts/mac-run-tev.sh)
endif()
if (TEV_SUPPORT_HEIC)
if (TEV_USE_LIBHEIF)
set(TEV_SOURCES ${TEV_SOURCES} include/tev/imageio/HeifImageLoader.h src/imageio/HeifImageLoader.cpp)
endif()

Expand Down Expand Up @@ -232,20 +234,22 @@ include_directories(
${UTFCPP_INCLUDE}
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
if (TEV_SUPPORT_HEIC)
if (TEV_USE_LIBHEIF)
include_directories(${LIBHEIF_INCLUDE})
endif()

set(TEV_DEFINITIONS -DTEV_VERSION="${TEV_VERSION_ARCH}")
if (APPLE)
# Starting with macOS Mojave OpenGL is deprecated. tev will switch
# away from OpenGL once the underlying nanogui does, so there is no
# point in keeping the warnings around.
# Starting with macOS Mojave OpenGL is deprecated. tev uses metal by default but can optionally be targeted at GL, so there is no point
# in keeping the warnings around.
set(TEV_DEFINITIONS ${TEV_DEFINITIONS} -DGL_SILENCE_DEPRECATION)
endif()
if (TEV_SUPPORT_HEIC)
set(TEV_DEFINITIONS ${TEV_DEFINITIONS} -DTEV_SUPPORT_HEIC)
endif()
if (TEV_USE_LIBHEIF)
set(TEV_DEFINITIONS ${TEV_DEFINITIONS} -DTEV_USE_LIBHEIF)
endif()

add_definitions(${TEV_DEFINITIONS} ${NANOGUI_EXTRA_DEFS})

Expand Down
14 changes: 10 additions & 4 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@ set(OPENEXR_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
set(OPENEXR_BUILD_TOOLS OFF CACHE BOOL " " FORCE)
add_subdirectory(openexr)

# Compile libde265 (dependency of libheif, which follows)
if (TEV_SUPPORT_HEIC)
# Compile libde265 (dependency of libheif, which follows)
set(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
set(ENABLE_SDL OFF CACHE BOOL " " FORCE)
add_subdirectory(libde265 EXCLUDE_FROM_ALL)

set(LIBDE265_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libde265" CACHE PATH " " FORCE)
set(LIBDE265_LIBRARY de265)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/libde265")
endif()

# Compile libheif

# Compile libheif
if (TEV_USE_LIBHEIF)
# General build config
set(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
set(BUILD_TESTING OFF CACHE BOOL " " FORCE)
Expand All @@ -88,16 +89,21 @@ if (TEV_SUPPORT_HEIC)
set(WITH_GDK_PIXBUF OFF CACHE BOOL " " FORCE)

# Codecs
set(WITH_LIBDE265 ${TEV_SUPPORT_HEIC})
set(WITH_X265 OFF CACHE BOOL " " FORCE)
set(WITH_OpenH264_ENCODER OFF CACHE BOOL " " FORCE)
set(WITH_OpenH264_DECODER OFF CACHE BOOL " " FORCE)

# TODO: Add aom as dependency to let libheif decode avif images for us.
# Also consider adding JPEG2000 support via libheif.
set(WITH_AOM_ENCODER OFF CACHE BOOL " " FORCE)
set(WITH_AOM_DECODER OFF CACHE BOOL " " FORCE)

# TODO: Check whether libsharpyuv is needed...
# libsharpyuv is not needed for us, because we're not interested in converting from RGB to YUV. tev is primarily an image viewer that
# goes from YUV to RGB upon loading images, where libsharpyuv does nothing. See https://www.ctrl.blog/entry/webp-sharp-yuv.html for more
# info.
set(WITH_LIBSHARPYUV OFF CACHE BOOL " " FORCE)

add_subdirectory(libheif EXCLUDE_FROM_ALL)

set(LIBHEIF_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libheif/libheif/api" "${CMAKE_CURRENT_BINARY_DIR}/libheif" PARENT_SCOPE)
Expand Down
43 changes: 23 additions & 20 deletions src/HelpWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ HelpWindow::HelpWindow(Widget* parent, bool supportsHdr, function<void()> closeC

addRow(imageSelection, "Left Click", "Select hovered image");
addRow(imageSelection, "1…9", "Select N-th image");
addRow(imageSelection, "Down/Up or S/W or J/K or Ctrl+Tab/Ctrl+Shift+Tab", "Select next/previous image");
addRow(imageSelection, "Down/Up or S/W or Ctrl+Tab/Ctrl+Shift+Tab", "Select next/previous image");
addRow(imageSelection, "Home/End", "Select first/last image");
addRow(imageSelection, "Space", "Toggle playback of images as video");

addRow(imageSelection, "Click & Drag (+Shift/" + COMMAND + ")", "Translate image");
addRow(imageSelection, "Click & Drag or H/J/K/L (+Shift/Ctrl)", "Translate image");
addRow(imageSelection, "Click & Drag+C (hold)", "Crop image");
addRow(imageSelection, "+/- or Scroll (+Shift/" + COMMAND + ")", "Zoom in/out of image");
addRow(imageSelection, "+/- or Scroll (+Shift/Ctrl)", "Zoom in/out of image");

addRow(imageSelection, COMMAND + "+0", "Zoom to actual size");
addRow(imageSelection, COMMAND + "+9/F", "Zoom to fit");
Expand All @@ -94,7 +94,7 @@ HelpWindow::HelpWindow(Widget* parent, bool supportsHdr, function<void()> closeC
addRow(imageSelection, "L", "Display the image as if on an LDR screen");
}

addRow(imageSelection, "Shift+Right/Left or Shift+D/A or Shift+L/H", "Select next/previous tonemap");
addRow(imageSelection, "Shift+Right/Left or Shift+D/A", "Select next/previous tonemap");

addRow(imageSelection, "E/Shift+E", "Increase/decrease exposure by 0.5");
addRow(imageSelection, "O/Shift+O", "Increase/decrease offset by 0.1");
Expand All @@ -114,18 +114,18 @@ HelpWindow::HelpWindow(Widget* parent, bool supportsHdr, function<void()> closeC
addRow(referenceSelection, "Shift (hold)", "View currently selected reference");
addRow(referenceSelection, "Shift+Left Click or Right Click", "Select hovered image as reference");
addRow(referenceSelection, "Shift+1…9", "Select N-th image as reference");
addRow(referenceSelection, "Shift+Down/Up or Shift+S/W or Shift+J/K", "Select next/previous image as reference");
addRow(referenceSelection, "Shift+Down/Up or Shift+S/W", "Select next/previous image as reference");

addRow(referenceSelection, "Ctrl (hold)", "View selected image if reference is selected");
addRow(referenceSelection, "Ctrl+Right/Left or Ctrl+D/A or Ctrl+L/H", "Select next/previous error metric");
addRow(referenceSelection, "Ctrl+Right/Left or Ctrl+D/A", "Select next/previous error metric");

new Label{shortcuts, "Channel group options", "sans-bold", 18};
auto groupSelection = new Widget{shortcuts};
groupSelection->set_layout(new BoxLayout{Orientation::Vertical, Alignment::Fill, 0, 0});

addRow(groupSelection, "Left Click", "Select hovered channel group");
addRow(groupSelection, "Ctrl+1…9", "Select N-th channel group");
addRow(groupSelection, "Right/Left or D/A or L/H or ]/[", "Select next/previous channel group");
addRow(groupSelection, "Right/Left or D/A or ]/[", "Select next/previous channel group");
addRow(groupSelection, "X", "Explode current channel group");

new Label{shortcuts, "Interface", "sans-bold", 18};
Expand Down Expand Up @@ -178,21 +178,24 @@ HelpWindow::HelpWindow(Widget* parent, bool supportsHdr, function<void()> closeC

addSpacer(about, 30);

addLibrary(about, "args", "", "Single-Header Argument Parsing Library");
addLibrary(about, "clip", "", "Cross-Platform Clipboard Library");
addLibrary(about, "{fmt}", "", "Fast & Safe Formatting Library");
addLibrary(about, "Glad", "", "Multi-Language GL Loader-Generator");
addLibrary(about, "GLFW", "", "OpenGL Desktop Development Library");
addLibrary(about, "args", "", "Single-header argument parsing library");
addLibrary(about, "clip", "", "Cross-platform clipboard library");
addLibrary(about, "{fmt}", "", "Fast & safe formatting library");
addLibrary(about, "Glad", "", "Multi-language GL loader-generator");
addLibrary(about, "GLFW", "", "OpenGL desktop development library");
#ifdef TEV_SUPPORT_HEIC
addLibrary(about, "libde265 (+libheif)", "", "HEIC Support");
addLibrary(about, "libde265", "", "Open h.265 video codec implementation.");
#endif
addLibrary(about, "NanoGUI", "", "Small GUI Library");
addLibrary(about, "NanoVG", "", "Small Vector Graphics Library");
addLibrary(about, "OpenEXR", "", "High Dynamic-Range (HDR) Image File Format");
addLibrary(about, "qoi", "", "File Format for Fast, Lossless Image Compression");
addLibrary(about, "stb_image(_write)", "", "Single-Header Library for Loading and Writing Images");
addLibrary(about, "tinylogger", "", "Minimal Pretty-Logging Library");
addLibrary(about, "UTF8-CPP", "", "Lightweight UTF-8 String Manipulation Library");
#ifdef TEV_USE_LIBHEIF
addLibrary(about, "libheif", "", "HEIF and avif file format decoder and encoder");
#endif
addLibrary(about, "NanoGUI", "", "Small GUI library");
addLibrary(about, "NanoVG", "", "Small vector graphics library");
addLibrary(about, "OpenEXR", "", "High dynamic-range (HDR) image file format");
addLibrary(about, "qoi", "", "File format for fast, lossless image compression");
addLibrary(about, "stb_image(_write)", "", "Single-header library for loading and writing images");
addLibrary(about, "tinylogger", "", "Minimal pretty-logging library");
addLibrary(about, "UTF8-CPP", "", "Lightweight UTF-8 string manipulation library");

// Make the keybindings page as big as is needed to fit the about tab
perform_layout(screen()->nvg_context());
Expand Down
2 changes: 1 addition & 1 deletion src/ImageCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool ImageCanvas::scroll_event(const Vector2i& p, const Vector2f& rel) {
// There is no explicit access to the currently pressed modifier keys here, so we need to directly ask GLFW.
if (glfwGetKey(glfwWindow, GLFW_KEY_LEFT_SHIFT) || glfwGetKey(glfwWindow, GLFW_KEY_RIGHT_SHIFT)) {
scaleAmount /= 10;
} else if (glfwGetKey(glfwWindow, SYSTEM_COMMAND_LEFT) || glfwGetKey(glfwWindow, SYSTEM_COMMAND_RIGHT)) {
} else if (glfwGetKey(glfwWindow, GLFW_KEY_LEFT_CONTROL) || glfwGetKey(glfwWindow, GLFW_KEY_RIGHT_CONTROL)) {
scaleAmount /= std::log2(1.1f);
}

Expand Down
32 changes: 26 additions & 6 deletions src/ImageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ bool ImageViewer::mouse_motion_event(const nanogui::Vector2i& p, const nanogui::
// There is no explicit access to the currently pressed modifier keys here, so we need to directly ask GLFW.
if (glfwGetKey(glfwWindow, GLFW_KEY_LEFT_SHIFT) || glfwGetKey(glfwWindow, GLFW_KEY_RIGHT_SHIFT)) {
relativeMovement /= 10;
} else if (glfwGetKey(glfwWindow, SYSTEM_COMMAND_LEFT) || glfwGetKey(glfwWindow, SYSTEM_COMMAND_RIGHT)) {
} else if (glfwGetKey(glfwWindow, GLFW_KEY_LEFT_CONTROL) || glfwGetKey(glfwWindow, GLFW_KEY_RIGHT_CONTROL)) {
relativeMovement /= std::log2(1.1f);
}

Expand Down Expand Up @@ -858,7 +858,7 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
float scaleAmount = 1.0f;
if (modifiers & GLFW_MOD_SHIFT) {
scaleAmount /= 10;
} else if (modifiers & SYSTEM_COMMAND_MOD) {
} else if (modifiers & GLFW_MOD_CONTROL) {
scaleAmount /= std::log2(1.1f);
}

Expand Down Expand Up @@ -903,14 +903,14 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
} else {
removeImage(mCurrentImage);
}
} else if (key == GLFW_KEY_UP || key == GLFW_KEY_W || key == GLFW_KEY_K || key == GLFW_KEY_PAGE_UP ||
} else if (key == GLFW_KEY_UP || key == GLFW_KEY_W || key == GLFW_KEY_PAGE_UP ||
(key == GLFW_KEY_TAB && (modifiers & GLFW_MOD_CONTROL) && (modifiers & GLFW_MOD_SHIFT))) {
if (key != GLFW_KEY_TAB && (modifiers & GLFW_MOD_SHIFT)) {
selectReference(nextImage(mCurrentReference, Backward));
} else {
selectImage(nextImage(mCurrentImage, Backward));
}
} else if (key == GLFW_KEY_DOWN || key == GLFW_KEY_S || key == GLFW_KEY_J || key == GLFW_KEY_PAGE_DOWN ||
} else if (key == GLFW_KEY_DOWN || key == GLFW_KEY_S || key == GLFW_KEY_PAGE_DOWN ||
(key == GLFW_KEY_TAB && (modifiers & GLFW_MOD_CONTROL) && !(modifiers & GLFW_MOD_SHIFT))) {
if (key != GLFW_KEY_TAB && (modifiers & GLFW_MOD_SHIFT)) {
selectReference(nextImage(mCurrentReference, Forward));
Expand All @@ -919,7 +919,7 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
}
}

if (key == GLFW_KEY_RIGHT || key == GLFW_KEY_D || key == GLFW_KEY_L || key == GLFW_KEY_RIGHT_BRACKET) {
if (key == GLFW_KEY_RIGHT || key == GLFW_KEY_D || key == GLFW_KEY_RIGHT_BRACKET) {
if (modifiers & GLFW_MOD_SHIFT) {
setTonemap(static_cast<ETonemap>((tonemap() + 1) % NumTonemaps));
} else if (modifiers & GLFW_MOD_CONTROL) {
Expand All @@ -929,7 +929,7 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
} else {
selectGroup(nextGroup(mCurrentGroup, Forward));
}
} else if (key == GLFW_KEY_LEFT || key == GLFW_KEY_A || key == GLFW_KEY_H || key == GLFW_KEY_LEFT_BRACKET) {
} else if (key == GLFW_KEY_LEFT || key == GLFW_KEY_A || key == GLFW_KEY_LEFT_BRACKET) {
if (modifiers & GLFW_MOD_SHIFT) {
setTonemap(static_cast<ETonemap>((tonemap() - 1 + NumTonemaps) % NumTonemaps));
} else if (modifiers & GLFW_MOD_CONTROL) {
Expand All @@ -940,6 +940,26 @@ bool ImageViewer::keyboard_event(int key, int scancode, int action, int modifier
selectGroup(nextGroup(mCurrentGroup, Backward));
}
}

float translationAmount = 64.0f;
if (modifiers & GLFW_MOD_SHIFT) {
translationAmount /= 8.0f;
if (modifiers & GLFW_MOD_CONTROL) {
translationAmount /= 8.0f;
}
} else if (modifiers & GLFW_MOD_CONTROL) {
translationAmount *= 8.0f;
}

if (key == GLFW_KEY_H) {
mImageCanvas->translate({-translationAmount, 0});
} else if (key == GLFW_KEY_L) {
mImageCanvas->translate({translationAmount, 0});
} else if (key == GLFW_KEY_J) {
mImageCanvas->translate({0, translationAmount});
} else if (key == GLFW_KEY_K) {
mImageCanvas->translate({0, -translationAmount});
}
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions src/imageio/ImageLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifdef _WIN32
# include <tev/imageio/DdsImageLoader.h>
#endif
#ifdef TEV_SUPPORT_HEIC
#ifdef TEV_USE_LIBHEIF
# include <tev/imageio/HeifImageLoader.h>
#endif

Expand All @@ -30,7 +30,7 @@ const vector<unique_ptr<ImageLoader>>& ImageLoader::getLoaders() {
#ifdef _WIN32
imageLoaders.emplace_back(new DdsImageLoader());
#endif
#ifdef TEV_SUPPORT_HEIC
#ifdef TEV_USE_LIBHEIF
imageLoaders.emplace_back(new HeifImageLoader());
#endif
imageLoaders.emplace_back(new QoiImageLoader());
Expand Down
Loading