Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement lanczos for upscaling to get crispier images #445

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
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
72 changes: 53 additions & 19 deletions YACReader/YACReader.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@ DEFINES += YACREADER

#load default build flags
include (../config.pri)

CONFIG(7zip) {
include(../compressed_archive/wrapper.pri)
} else:CONFIG(unarr) {
include(../compressed_archive/unarr/unarr-wrapper.pri)
} else:CONFIG(libarchive) {
include(../compressed_archive/libarchive/libarchive-wrapper.pri)
} else {
error(No compression backend specified. Did you mess with the build system?)
}

include(../custom_widgets/custom_widgets_yacreader.pri)
include(../image_processing/image_processing.pri)
include (../dependencies/pdf_backend.pri)
include(../shortcuts_management/shortcuts_management.pri)

include(../third_party/QsLog/QsLog.pri)

CONFIG(force_angle) {
contains(QMAKE_TARGET.arch, x86_64) {
Expand All @@ -30,7 +46,7 @@ CONFIG(force_angle) {
}
}

SOURCES += main.cpp
SOURCES += main.cpp \

INCLUDEPATH += ../common \
../custom_widgets
Expand All @@ -39,6 +55,9 @@ INCLUDEPATH += ../common \
INCLUDEPATH += ../common/gl
}

message (HOST:$$QMAKE_HOST.arch)
message (TARGET:$$QMAKE_TARGET.arch)

#there are going to be two builds for windows, OpenGL based and ANGLE based
win32 {
CONFIG(force_angle) {
Expand All @@ -55,6 +74,12 @@ win32 {
msvc {
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG

# Enable AVX and AVX2 support
QMAKE_CXXFLAGS += /arch:AVX

# Enable AVX2 if supported
win32:QMAKE_CXXFLAGS += /arch:AVX2
}
CONFIG -= embed_manifest_exe
}
Expand All @@ -65,9 +90,33 @@ macx {
LIBS += -framework Foundation -framework ApplicationServices -framework AppKit

lessThan(QT_MAJOR_VERSION, 6): QT += macextras

contains(QMAKE_TARGET.arch, arm64) {
QMAKE_CXXFLAGS += -mfpu=neon -mfloat-abi=hard
}

contains(QMAKE_TARGET.arch, x86_64) {
QMAKE_CXXFLAGS += -msse4.2 -mavx2 -mfma
}
} else {
unix|mingw {
contains(QMAKE_TARGET.arch, arm) {
QMAKE_CXXFLAGS += -mfpu=neon -mfloat-abi=hard
} else {
# Enable general SIMD optimizations
QMAKE_CXXFLAGS += -msse2 # Baseline for x86

# Architecture-specific optimizations (adjust as needed)
contains(QMAKE_TARGET.arch, x86_64) {
QMAKE_CXXFLAGS += -mavx2 -mfma
} else { # Assuming x86 (32-bit)
QMAKE_CXXFLAGS += -msse4.2
}
}
}
}

QT += network widgets core multimedia svg
QT += network widgets core multimedia svg concurrent

greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat

Expand Down Expand Up @@ -106,7 +155,7 @@ HEADERS += ../common/comic.h \
../common/exit_check.h \
../common/scroll_management.h \
../common/opengl_checker.h \
../common/pdf_comic.h
../common/pdf_comic.h \

!CONFIG(no_opengl) {
HEADERS += ../common/gl/yacreader_flow_gl.h \
Expand Down Expand Up @@ -143,31 +192,16 @@ SOURCES += ../common/comic.cpp \
../common/yacreader_global_gui.cpp \
../common/exit_check.cpp \
../common/scroll_management.cpp \
../common/opengl_checker.cpp
../common/opengl_checker.cpp \

!CONFIG(no_opengl) {
SOURCES += ../common/gl/yacreader_flow_gl.cpp \
goto_flow_gl.cpp
}

include(../custom_widgets/custom_widgets_yacreader.pri)

CONFIG(7zip) {
include(../compressed_archive/wrapper.pri)
} else:CONFIG(unarr) {
include(../compressed_archive/unarr/unarr-wrapper.pri)
} else:CONFIG(libarchive) {
include(../compressed_archive/libarchive/libarchive-wrapper.pri)
} else {
error(No compression backend specified. Did you mess with the build system?)
}
include(../shortcuts_management/shortcuts_management.pri)

RESOURCES += yacreader_images.qrc \
yacreader_files.qrc

include(../third_party/QsLog/QsLog.pri)

RC_FILE = icon.rc

macx {
Expand Down
15 changes: 7 additions & 8 deletions YACReader/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "notifications_label_widget.h"
#include "comic_db.h"
#include "shortcuts_manager.h"
#include "resize_image.h"

#include "opengl_checker.h"

Expand Down Expand Up @@ -387,16 +388,14 @@ void Viewer::updateContentSize()
if (zoom != 100) {
pagefit.scale(floor(pagefit.width() * zoom / 100.0f), 0, Qt::KeepAspectRatioByExpanding);
}
// apply scaling
// apply size to the container
content->resize(pagefit);

// TODO: updtateContentSize should only scale the pixmap once
if (devicePixelRatioF() > 1) // only in HDPI displays
{
QPixmap page = currentPage->scaled(content->width() * devicePixelRatioF(), content->height() * devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
page.setDevicePixelRatio(devicePixelRatioF());
content->setPixmap(page);
}
// scale the image to fit the container
auto devicePixelRatioF = content->devicePixelRatioF();
QPixmap page = smartScalePixmap(*currentPage, content->width() * devicePixelRatioF, content->height() * devicePixelRatioF); // currentPage->scaled(content->width() * devicePixelRatioF(), content->height() * devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
page.setDevicePixelRatio(devicePixelRatioF);
content->setPixmap(page);

emit backgroundChanges();
}
Expand Down
2 changes: 1 addition & 1 deletion compileOSX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fi

echo "Preparing apps for release, Done."

dest="YACReader-$VERSION.$BUILD_NUMBER MacOSX-$ARCH_NAME ${QT_VERSION}"
dest="YACReader-$VERSION.$BUILD_NUMBER macos-$ARCH_NAME ${QT_VERSION}"
echo "Copying to destination folder ${dest}"
mkdir -p "$dest"
cp -R YACReader.app "${dest}/YACReader.app"
Expand Down
12 changes: 6 additions & 6 deletions dmg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "YACReader-#VERSION#.#BUILD_NUMBER##QT_VERSION#",
"title": "YACReader#VERSION#.#BUILD_NUMBER##QT_VERSION#",
"icon": "icon.icns",
"background": "background.png",
"window": {
Expand All @@ -19,31 +19,31 @@
"x": 80,
"y": 90,
"type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/YACReader.app"
"path": "YACReader-#VERSION#.#BUILD_NUMBER# macos-#ARCH_NAME# #QT_VERSION#/YACReader.app"
},
{
"x": 235,
"y": 90,
"type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/YACReaderLibrary.app"
"path": "YACReader-#VERSION#.#BUILD_NUMBER# macos-#ARCH_NAME# #QT_VERSION#/YACReaderLibrary.app"
},
{
"x": 470,
"y": 295,
"type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/YACReaderLibraryServer"
"path": "YACReader-#VERSION#.#BUILD_NUMBER# macos-#ARCH_NAME# #QT_VERSION#/YACReaderLibraryServer"
},
{
"x": 120,
"y": 295,
"type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/README.md"
"path": "YACReader-#VERSION#.#BUILD_NUMBER# macos-#ARCH_NAME# #QT_VERSION#/README.md"
},
{
"x": 290,
"y": 295,
"type": "file",
"path": "YACReader-#VERSION#.#BUILD_NUMBER# MacOSX-#ARCH_NAME# #QT_VERSION#/COPYING.txt"
"path": "YACReader-#VERSION#.#BUILD_NUMBER# macos-#ARCH_NAME# #QT_VERSION#/COPYING.txt"
}
]
}
8 changes: 8 additions & 0 deletions image_processing/image_processing.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD

SOURCES += \
$$PWD/resize_image.cpp

HEADERS += \
$$PWD/resize_image.h
Loading