 |
Geometrize
1.0
An application for geometrizing images into geometric primitives
|
|
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...
|
|
◆ convertImageToBitmapWithDownscaling()
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
-
image | The image to create the bitmap data from. |
- Returns
- The new bitmap data.
34 QImage im{image.copy()};
37 if(prefs.isImageTaskImageResizeEnabled()) {
39 const QSize imageSize{im.size()};
41 if(sizeThreshold.first <
static_cast<unsigned int>(imageSize.width())
42 || sizeThreshold.second <
static_cast<unsigned int>(imageSize.height())) {
43 im = image.scaled(sizeThreshold.first, sizeThreshold.second, Qt::KeepAspectRatio, Qt::SmoothTransformation).convertToFormat(QImage::Format_RGBA8888);
◆ convertImageToRgba8888()
QImage geometrize::image::convertImageToRgba8888 |
( |
const QImage & |
image | ) |
|
convertImageToRgba8888 Returns a copy of the image in the RGBA8888 format.
- Parameters
-
image | The image to convert. |
- Returns
- A copy of the given image in RGBA8888 format.
84 return image.convertToFormat(QImage::Format_RGBA8888);
◆ createBitmap()
Bitmap geometrize::image::createBitmap |
( |
const QImage & |
image | ) |
|
createBitmap Creates a bitmap data object from the given image.
- Parameters
-
image | The image to create the bitmap data from. |
- Returns
- The new bitmap data.
24 assert(!image.isNull() &&
"Image is null, will fail to create bitmap data");
25 assert((image.width() != 0 && image.height() != 0) &&
"Image has zero width or height");
26 assert((image.format() == QImage::Format_RGBA8888) &&
"Cannot create bitmap data from a non-RGBA8888 image");
28 const std::vector<uchar> data(image.bits(), image.bits() + image.sizeInBytes());
29 return Bitmap(image.width(), image.height(), data);
◆ createImage()
QImage geometrize::image::createImage |
( |
const Bitmap & |
data | ) |
|
createImage Creates an image from the bitmap data object. Assumes RGBA8888 format.
- Parameters
-
data | The bitmap data, RGBA8888 bytes (must be a multiple of 4). |
- Returns
- The pixmap created from the bytes data.
50 if(data.getWidth() == 0 || data.getHeight() == 0) {
51 assert(0 &&
"Bad bitmap data");
56 return QImage(data.getDataRef().data(), data.getWidth(), data.getHeight(), QImage::Format_RGBA8888);
◆ createPixmap()
QPixmap geometrize::image::createPixmap |
( |
const Bitmap & |
data | ) |
|
createPixmap Creates a pixmap from the bitmap data object. Assumes RGBA8888 format.
- Parameters
-
data | The bitmap data, RGBA8888 bytes (must be a multiple of 4). |
- Returns
- The pixmap created from the bytes data.
◆ loadImage()
QImage geometrize::image::loadImage |
( |
const std::string & |
filePath | ) |
|
loadImage Loads an image from the image at the file path. Converts to RGBA8888 format.
- Parameters
-
filePath | The file path to the image. |
- Returns
- The image loaded from the image file.
66 const QString path = QString::fromStdString(filePath);
68 if(QFile(path).exists()) {
71 image = QImage(QUrl(path).toLocalFile());
75 assert(0 &&
"Bad image data");
79 return image.convertToFormat(QImage::Format_RGBA8888);
QImage createImage(const Bitmap &data)
createImage Creates an image from the bitmap data object. Assumes RGBA8888 format.
Definition: imageloader.cpp:48
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
Bitmap createBitmap(const QImage &image)
createBitmap Creates a bitmap data object from the given image.
Definition: imageloader.cpp:22
The GlobalPreferences class models the preferences associated with the application as a whole....
Definition: globalpreferences.h:44
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32