2022-10-23 12:32:20 -05:00
|
|
|
#include <string>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <filesystem>
|
2022-10-29 12:27:10 -05:00
|
|
|
#include <QtGui/QImageReader>
|
|
|
|
|
#include <QtCore/QDebug>
|
2022-10-23 12:32:20 -05:00
|
|
|
|
2024-11-16 14:10:54 -06:00
|
|
|
class LocalImage {
|
|
|
|
|
public:
|
|
|
|
|
LocalImage ();
|
|
|
|
|
LocalImage (const QImage& image);
|
|
|
|
|
|
|
|
|
|
void setImage (const QImage& image);
|
|
|
|
|
const uchar* bits () const;
|
|
|
|
|
int width () const;
|
|
|
|
|
int height () const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QImage _image;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LocalImage::LocalImage() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalImage::LocalImage(const QImage& image) {
|
|
|
|
|
setImage(image);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void LocalImage::setImage (const QImage& image) {
|
|
|
|
|
_image = image;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const uchar* LocalImage::bits() const {
|
|
|
|
|
return _image.bits();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int LocalImage::width() const {
|
|
|
|
|
return _image.width();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LocalImage::height() const {
|
|
|
|
|
return _image.height();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-10-23 12:32:20 -05:00
|
|
|
int main (int argc, char** argv) {
|
|
|
|
|
|
|
|
|
|
std::cout << "Hello, Image!" << std::endl;
|
|
|
|
|
|
2023-03-05 09:38:39 -06:00
|
|
|
QImageReader reader("mona.jpg");
|
2022-10-29 12:27:10 -05:00
|
|
|
reader.setAutoTransform(true);
|
2022-10-23 12:32:20 -05:00
|
|
|
|
2022-10-29 12:27:10 -05:00
|
|
|
QImage image = reader.read();
|
|
|
|
|
if (image.isNull()) {
|
|
|
|
|
return false;
|
2022-10-23 12:32:20 -05:00
|
|
|
}
|
|
|
|
|
|
2022-10-29 12:27:10 -05:00
|
|
|
QImage image_rgb = image.convertToFormat(QImage::Format_RGB888);
|
|
|
|
|
QImage image_rgba = image.convertToFormat(QImage::Format_RGBA8888);
|
2022-10-23 12:32:20 -05:00
|
|
|
|
2023-03-05 09:38:39 -06:00
|
|
|
qInfo() << image;
|
|
|
|
|
qInfo() << image_rgb;
|
|
|
|
|
qInfo() << image_rgba;
|
2022-10-23 12:32:20 -05:00
|
|
|
|
2023-03-05 09:38:39 -06:00
|
|
|
// QImage(QSize(220, 197),format=QImage::Format_RGB32,depth=32,devicePixelRatio=1,bytesPerLine=880,sizeInBytes=173360)
|
|
|
|
|
// QImage(QSize(220, 197),format=QImage::Format_RGB888,depth=24,devicePixelRatio=1,bytesPerLine=660,sizeInBytes=130020)
|
|
|
|
|
// QImage(QSize(220, 197),format=QImage::Format_RGBA8888,depth=32,devicePixelRatio=1,bytesPerLine=880,sizeInBytes=173360)
|
2022-10-23 12:32:20 -05:00
|
|
|
|
2022-10-29 12:27:10 -05:00
|
|
|
const uchar* bits = image.bits();
|
|
|
|
|
const uchar* bits_rgb = image_rgb.bits();
|
|
|
|
|
const uchar* bits_rgba = image_rgba.bits();
|
2022-10-23 12:32:20 -05:00
|
|
|
|
2024-11-16 14:10:54 -06:00
|
|
|
LocalImage img(image);
|
|
|
|
|
qInfo() << img.width();
|
|
|
|
|
qInfo() << img.height();
|
|
|
|
|
|
2022-10-23 12:32:20 -05:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|