Merge pull request #1467 from Cogitri/constexpr

refactor(Util): add DPI_NORMALIZATION_FACTOR
presentation
Ulrich Huber 7 years ago committed by GitHub
commit fc0e823078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/control/ClipboardHandler.cpp
  2. 10
      src/control/Control.cpp
  3. 9
      src/control/jobs/ImageExport.cpp
  4. 8
      src/model/FormatDefinitions.cpp
  5. 2
      src/util/Util.h

@ -1,6 +1,7 @@
#include "ClipboardHandler.h"
#include "Control.h"
#include "Util.h"
#include "view/DocumentView.h"
#include <config.h>
@ -203,7 +204,7 @@ bool ClipboardHandler::copy()
DocumentView view;
double dpiFactor = 1.0 / 72.0 * 300.0;
double dpiFactor = 1.0 / Util::DPI_NORMALIZATION_FACTOR * 300.0;
int width = selection->getWidth() * dpiFactor;
int height = selection->getHeight() * dpiFactor;

@ -115,7 +115,7 @@ Control::Control(GladeSearchpath* gladeSearchPath)
this->zoom = new ZoomControl();
this->zoom->setZoomStep(this->settings->getZoomStep() / 100.0);
this->zoom->setZoomStepScroll(this->settings->getZoomStepScroll() / 100.0);
this->zoom->setZoom100Value(this->settings->getDisplayDpi() / 72.0);
this->zoom->setZoom100Value(this->settings->getDisplayDpi() / Util::DPI_NORMALIZATION_FACTOR);
this->toolHandler = new ToolHandler(this, this, this->settings);
this->toolHandler->loadSettings();
@ -2258,7 +2258,7 @@ void Control::showSettings()
this->zoom->setZoomStep(settings->getZoomStep() / 100.0);
this->zoom->setZoomStepScroll(settings->getZoomStepScroll() / 100.0);
this->zoom->setZoom100Value(settings->getDisplayDpi() / 72.0);
this->zoom->setZoom100Value(settings->getDisplayDpi() / Util::DPI_NORMALIZATION_FACTOR);
getWindow()->getXournal()->getHandRecognition()->reload();
@ -3067,8 +3067,10 @@ void Control::clipboardPasteImage(GdkPixbuf* img)
auto image = new Image();
image->setImage(img);
auto width = static_cast<double>(gdk_pixbuf_get_width(img)) / settings->getDisplayDpi() * 72.0;
auto height = static_cast<double>(gdk_pixbuf_get_height(img)) / settings->getDisplayDpi() * 72.0;
auto width =
static_cast<double>(gdk_pixbuf_get_width(img)) / settings->getDisplayDpi() * Util::DPI_NORMALIZATION_FACTOR;
auto height = static_cast<double>(gdk_pixbuf_get_height(img)) / settings->getDisplayDpi() *
Util::DPI_NORMALIZATION_FACTOR;
int pageNr = getCurrentPageNo();
if (pageNr == -1)

@ -2,6 +2,7 @@
#include "control/jobs/ProgressListener.h"
#include "model/Document.h"
#include "Util.h"
#include "view/PdfView.h"
#include <cairo-svg.h>
@ -55,10 +56,10 @@ void ImageExport::createSurface(double width, double height, int id)
if (format == EXPORT_GRAPHICS_PNG)
{
this->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
width * this->pngDpi / 72.0,
height * this->pngDpi / 72.0);
width * this->pngDpi / Util::DPI_NORMALIZATION_FACTOR,
height * this->pngDpi / Util::DPI_NORMALIZATION_FACTOR);
this->cr = cairo_create(this->surface);
double factor = this->pngDpi / 72.0;
double factor = this->pngDpi / Util::DPI_NORMALIZATION_FACTOR;
cairo_scale(this->cr, factor, factor);
}
else if (format == EXPORT_GRAPHICS_SVG)
@ -193,7 +194,7 @@ void ImageExport::exportGraphics(ProgressListener* stateListener)
stateListener->setMaximumState(selectedCount);
DocumentView view;
double zoom = this->pngDpi / 72.0;
double zoom = this->pngDpi / Util::DPI_NORMALIZATION_FACTOR;
int current = 0;
for (int i = 0; i < count; i++)

@ -1,11 +1,7 @@
#include "FormatDefinitions.h"
#include "Util.h"
#include <i18n.h>
const FormatUnits XOJ_UNITS[] = {
{ "cm", 28.346 },
{ "in", 72.0 },
{ "points", 1.0 }
};
const FormatUnits XOJ_UNITS[] = {{"cm", 28.346}, {"in", Util::DPI_NORMALIZATION_FACTOR}, {"points", 1.0}};
const int XOJ_UNIT_COUNT = sizeof(XOJ_UNITS) / sizeof(FormatUnits);

@ -62,6 +62,8 @@ extern void writeCoordinateString(OutputStream* out, double xVal, double yVal);
constexpr const gchar* PRECISION_FORMAT_STRING = "%.8f";
constexpr const auto DPI_NORMALIZATION_FACTOR = 72.0;
} // namespace Util
static const size_t npos = std::numeric_limits<size_t>::max();

Loading…
Cancel
Save