QImageViewer | image viewer for Qt - Qt version & gt | Computer Vision library
kandi X-RAY | QImageViewer Summary
kandi X-RAY | QImageViewer Summary
Qt version >= 5.0.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of QImageViewer
QImageViewer Key Features
QImageViewer Examples and Code Snippets
Community Discussions
Trending Discussions on QImageViewer
QUESTION
I'm beginner in Python and PyQt. I try to create image viewer based on acbetter's code and want to add image crop function. Using these two codes, ultimately I want to create a code in which I can open a certain image and crop specific part of the image and show it in another window. Would you like to help how to combine these two codes?
- acbetter's image viewer code https://gist.github.com/acbetter/32c575803ec361c3e82064e60db4e3e0
ANSWER
Answered 2020-Feb-11 at 06:20Implementing the crop in a viewer based on a QScrollArea with a QLabel is unnecessarily complicated since the transformation is complicated to track, instead implement the same logic with QGraphicsView, QGraphicsScene and QGraphicsPixmapItem. So much of the logic is already implemented as I show below:
QUESTION
I created a QLabel and set it's movie to a QMovie object with an animated gif. Then in the resizeEvent of my app I resize and move the label, so that it is centered/fit to the layout. This works fine but the movie has a lot of fine lines which get totally garbled in the resize operation, it seems there is no anti-aliasing. So either I am using the wrong resize method, or I need to set anti-aliasing somewhere right? There is nothing in the QMovie or QLabel documentation to suggest how to do this. I did read that the QMovie is inherited from a QImageReader, though that too has no property for anti-aliasing that I could find.
EDIT
I did somewhat get this to work, but it's still not quite right. I found that QMovie has a setScaledSize method which actually scales the underlying QImageViewer. Then I just have the label adjust to it's contents, namely the movie. Using the following code I am able to resize the movie with proper anti-aliasing, however it is quite "jumpy" and "flickery" during resize so obviously I'm not doing this quite "right". Also it somehow loses it's aspect ratio sometimes. Still looking for the correct way to do this... Maybe a QLabel is the wrong way to go?
Here's a working example
...ANSWER
Answered 2018-May-04 at 02:20Ok I have this figured out now, with just a few tweaks to the code in my edited post. The secret is in keeping the label the full size of it's parent rect (in this case the size of the whole layout) and then scaling the movie within the label. Essentially you are internally scaling the movie, instead of having it automatically fill the contents of the label. From what I can tell this changes around the order of operations a bit and allows the movie to scale itself on render, instead of rendering the frame and then scaling it to the label size.
Working code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install QImageViewer
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page