Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Functions
geometrize::image Namespace Reference

Functions

Bitmap createBitmap (const QImage &image)
 createBitmap Creates a bitmap data object from the given image. More...
 
geometrize::Bitmap convertImageToBitmapWithDownscaling (const QImage &image)
 imageToBitmapWithDownscaling Creates a bitmap data object from the given image, downscaling in the process based on global preferences for image resizing More...
 
QImage createImage (const Bitmap &data)
 createImage Creates an image from the bitmap data object. Assumes RGBA8888 format. More...
 
QPixmap createPixmap (const Bitmap &data)
 createPixmap Creates a pixmap from the bitmap data object. Assumes RGBA8888 format. More...
 
QImage loadImage (const std::string &filePath)
 loadImage Loads an image from the image at the file path. Converts to RGBA8888 format. More...
 
QImage convertImageToRgba8888 (const QImage &image)
 convertImageToRgba8888 Returns a copy of the image in the RGBA8888 format. More...
 
QPixmap loadPixmap (const std::string &filePath)
 loadPixmap Loads a pixmap from the image at the file path. Converts to RGBA8888 format. More...
 

Function Documentation

geometrize::Bitmap geometrize::image::convertImageToBitmapWithDownscaling ( const QImage &  image)

imageToBitmapWithDownscaling Creates a bitmap data object from the given image, downscaling in the process based on global preferences for image resizing

Parameters
imageThe image to create the bitmap data from.
Returns
The new bitmap data.
31 {
32  QImage im{image.copy()};
33 
35  if(prefs.isImageTaskImageResizeEnabled()) {
36  const std::pair<std::uint32_t, std::uint32_t> sizeThreshold{prefs.getImageTaskResizeThreshold()};
37  const QSize imageSize{im.size()};
38 
39  if(sizeThreshold.first < static_cast<unsigned int>(imageSize.width())
40  || sizeThreshold.second < static_cast<unsigned int>(imageSize.height())) {
41  im = image.scaled(sizeThreshold.first, sizeThreshold.second, Qt::KeepAspectRatio, Qt::SmoothTransformation).convertToFormat(QImage::Format_RGBA8888);
42  }
43  }
44  return geometrize::image::createBitmap(im.convertToFormat(QImage::Format_RGBA8888));
45 }
The GlobalPreferences class models the preferences associated with the application as a whole...
Definition: globalpreferences.h:43
std::pair< std::uint32_t, std::uint32_t > getImageTaskResizeThreshold() const
getImageTaskResizeThreshold Gets the maximum dimensions of an image that can be used in an image task...
Definition: globalpreferences.cpp:618
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
Bitmap createBitmap(const QImage &image)
createBitmap Creates a bitmap data object from the given image.
Definition: imageloader.cpp:20

Here is the call graph for this function:

Here is the caller graph for this function:

QImage geometrize::image::convertImageToRgba8888 ( const QImage &  image)

convertImageToRgba8888 Returns a copy of the image in the RGBA8888 format.

Parameters
imageThe image to convert.
Returns
A copy of the given image in RGBA8888 format.
75 {
76  return image.convertToFormat(QImage::Format_RGBA8888);
77 }

Here is the caller graph for this function:

Bitmap geometrize::image::createBitmap ( const QImage &  image)

createBitmap Creates a bitmap data object from the given image.

Parameters
imageThe image to create the bitmap data from.
Returns
The new bitmap data.
21 {
22  assert(!image.isNull() && "Image is null, will fail to create bitmap data");
23  assert((image.width() != 0 && image.height() != 0) && "Image has zero width or height");
24  assert((image.format() == QImage::Format_RGBA8888) && "Cannot create bitmap data from a non-RGBA8888 image");
25 
26  const std::vector<uchar> data(image.bits(), image.bits() + image.sizeInBytes());
27  return Bitmap(image.width(), image.height(), data);
28 }

Here is the caller graph for this function:

QImage geometrize::image::createImage ( const Bitmap &  data)

createImage Creates an image from the bitmap data object. Assumes RGBA8888 format.

Parameters
dataThe bitmap data, RGBA8888 bytes (must be a multiple of 4).
Returns
The pixmap created from the bytes data.
47 {
48  if(data.getWidth() == 0 || data.getHeight() == 0) {
49  assert(0 && "Bad bitmap data");
50  return QImage();
51  }
52 
53  // Note! This takes a shallow copy of the data, and so depends on the bitmap itself continuing to live on
54  return QImage(data.getDataRef().data(), data.getWidth(), data.getHeight(), QImage::Format_RGBA8888);
55 }

Here is the caller graph for this function:

QPixmap geometrize::image::createPixmap ( const Bitmap &  data)

createPixmap Creates a pixmap from the bitmap data object. Assumes RGBA8888 format.

Parameters
dataThe bitmap data, RGBA8888 bytes (must be a multiple of 4).
Returns
The pixmap created from the bytes data.
58 {
59  return QPixmap::fromImage(createImage(data));
60 }
QImage createImage(const Bitmap &data)
createImage Creates an image from the bitmap data object. Assumes RGBA8888 format.
Definition: imageloader.cpp:46

Here is the call graph for this function:

Here is the caller graph for this function:

QImage geometrize::image::loadImage ( const std::string &  filePath)

loadImage Loads an image from the image at the file path. Converts to RGBA8888 format.

Parameters
filePathThe file path to the image.
Returns
The image loaded from the image file.
63 {
64  const QImage image(QString::fromStdString(filePath));
65 
66  if(image.isNull()) {
67  assert(0 && "Bad image data");
68  return image;
69  }
70 
71  return image.convertToFormat(QImage::Format_RGBA8888);
72 }

Here is the caller graph for this function:

QPixmap geometrize::image::loadPixmap ( const std::string &  filePath)

loadPixmap Loads a pixmap from the image at the file path. Converts to RGBA8888 format.

Parameters
filePathThe file path to the pixmap.
Returns
The pixmap loaded from the image file.
80 {
81  return QPixmap::fromImage(loadImage(filePath));
82 }
QImage loadImage(const std::string &filePath)
loadImage Loads an image from the image at the file path. Converts to RGBA8888 format.
Definition: imageloader.cpp:62

Here is the call graph for this function: