I have created a qt project that take screen shot of the desktop and compress it .As far as I have taken the screen shot and scaled it.The original screen shot is about 230kb size and while scaling it reduced up-to 60kb.My problem is I need to reduce the saved jpg to around 5-10kb size without loosing it's clarity of the image.I have searched for the libraries and add-on in Qt but couldn't find any one that could give the possible result
Is there any algorithms ,examples or compression techniques that could reduce the size drastically without loosing its clarity?
OS:Ubuntu 14.04,
qt-5.2.1
.Here given below code I have done so far:
int widthToScale= (QApplication::desktop()->screenGeometry().width()*60)/100;
int heightToScale=(QApplication::desktop()->screenGeometry().width()*60)/100;
QPixmap p=QPixmap::grabWindow(QApplication::desktop()->winId(),0,0,
QApplication::desktop()->screenGeometry().width(),
QApplication::desktop()->screenGeometry().height()).scaled(widthToScale,heightToScale,Qt::KeepAspectRatio,Qt::SmoothTransformation);
p.save(localpath,0,65);
Related
I have a webpage where I can add multiple video streams and display them like a mosaic.
This looks like this:
The videos can be resized, but when they get too small, the bitrate will lower (the stream adapts to the size of the video) and artefacts start to become visible.
I was wondering if there was any way I could keep the videos at a fixed size (large enough to get a higher bitrate) while scaling them down for the mosaic.
I've tried using the CSS scale feature, but I couldn't achieve the desired outcome. Maybe it's not possible at all, but I'd appreciate any tips you might have (keep in mind that I'm unable the change the stream itself).
Thanks!
I am currently developing an application. And my development computer resolution is 1366*768, I know how to make the application size auto resizable according to resolution. But the problem is in the labels used in application. If the resolution of the monitor is less than 1366*768, the labels becomes cramped and unable to see text, if i keep the font low, and if i use higher resolution monitor the text in those labels looks very tiny. I know one solution that is to check the resolution of monitor during the application start and assign appropriate font to the labels dynamically. But this method takes more time as i have to first create a list of resolution with appropriate font by using trial and error method. And this also requires lot of code. I was wondering if there is any feature or function in qt that i am unaware of to auto scale the font as per resolution. Thanks!
I have a Qt Widgets application using Qt styleSheet for the app look and feel. We want to add support for high-DPI displays, as on these, the app looks very small. The first step was thus to call:
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
This does most of the job and the app window is big enough. The only remaining issue is the resolution of the images used in style sheet.
Say that we have:
QCheckBox::indicator::unchecked {
image: url(:/res/checkbox_off.png);
}
MainWindow QFrame {
background-image: url(:/res/background.png);
}
When using high DPI scaling, these images get upscaled accordingly which is a problem. For high DPI, I would prefer to use higher resolution images to make them look as crisp as possible.
As expected, a naive approach of simply providing the images in higher resolution does not work - it makes images and controls twice as large (on both low and high DPI screens).
Qt documentation on QImageReader states that
The high resolution version is marked by the suffix #2x on the base name. The image read will have its device pixel ratio set to a value of 2.
However, I have provided these resources with twice the resolution, added them to qrc file, but the images displayed are still the same on device with pixel_ratio of 3.
Are there any other steps needed to make this automatic image loading work with stylesheets?
I am making a program with Qtcreator (using qt designer too).
I made some QSvgWidget buttons (What i wanted was a scalable image based button). They work but don't keep the aspect ratio of the image (aspect ratio needs to be 1:1).
I haven't been able to come up with a solution for this myself even after hours of trying.
I have tried:
QSizePolicy qsp(QSizePolicy::Preferred,QSizePolicy::Preferred);
qsp.setHeightForWidth(true);
ui->Widgetname->setSizePolicy(qsp);
But that doesn't work.
Some images of the problem:
Correct:
Incorrect:
I am new to working with Qt and coding.
What am I doing wrong?
I have created an application with a screen resolution of 640 x 360 for the nokia n8. It includes a lot of flickables, labels, etc. I want it to run on the nokia e6 with a resolution of 640 x 480.
Up to now I have simply copied the the QML file and modified it for the new resolution but it's getting a little tiresome to do it for each update. I want to know if there is any simple way I can get it to automatically fit the output to any screen resolution? Or if there is something else I can do to simplify my task. I would prefer not to use anchors because it makes it too complicated to design the QML file.
How about using QApplication::desktop()->availableGeometry() to set the geometry of your application window?
From the docs:
QDesktopWidget::availableGeometry()
Returns the available geometry of the screen with index screen. What is available will be subrect of screenGeometry() based on what the platform decides is available (for example excludes the dock and menu bar on Mac OS X, or the task bar on Windows).
Addressing your comment below:
does it re size the entire screen
The const in QDesktopWidget::availableGeometry() const tells you that you can be pretty sure that the function doesn't alter anything. You'll need to do the resizing yourself.
Edit: The QML docs should give you the information you need to automatically change your application geometry. You could either change the geometry of the QML object from C++ or define your available screen geometry as a Q_PROPERTY and access it from QML. I'd recommend the former, as hooking up to the signal QDesktopWidget::workAreaResized might help you on mobile devices where your available geometery may change.
Actually you should avoid hardcoding the interface pixel by pixel and start using anchors. Ther will be some phones that have yet another screen resolution and then you have to create new QML for each of them. With anchors you can let the content fill all available space